Skip to main content

AWS SDK extension for OpenTelemetry

Project description

pypi

This library provides components necessary to configure the OpenTelemetry SDK for tracing with AWS X-Ray.

Installation

pip install opentelemetry-sdk-extension-aws

Usage (AWS X-Ray IDs Generator)

Configure the OTel SDK TracerProvider with the provided custom IDs Generator to make spans compatible with the AWS X-Ray backend tracing service.

Install the OpenTelemetry SDK package.

pip install opentelemetry-sdk

Next, use the provided AwsXRayIdGenerator to initialize the TracerProvider.

import opentelemetry.trace as trace
from opentelemetry.sdk.extension.aws.trace import AwsXRayIdGenerator
from opentelemetry.sdk.trace import TracerProvider

trace.set_tracer_provider(
    TracerProvider(id_generator=AwsXRayIdGenerator())
)

Usage (AWS X-Ray Propagator)

NOTE: Because the parent context extracted from the X-Amzn-Trace-Id header assumes the context is _not_ sampled by default, users should make sure to add Sampled=1 to their X-Amzn-Trace-Id headers so that the child spans are sampled.

Use the provided AWS X-Ray Propagator to inject the necessary context into traces sent to external systems.

This can be done by either setting this environment variable:

export OTEL_PROPAGATORS = xray

Or by setting this propagator in your instrumented application:

from opentelemetry.propagate import set_global_textmap
from opentelemetry.sdk.extension.aws.trace.propagation.aws_xray_format import AwsXRayFormat

set_global_textmap(AwsXRayFormat())

Usage (AWS Resource Detectors)

Use the provided Resource Detectors to automatically populate attributes under the resource namespace of each generated span.

For example, if tracing with OpenTelemetry on an AWS EC2 instance, you can automatically populate resource attributes by creating a TraceProvider using the AwsEc2ResourceDetector:

import opentelemetry.trace as trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.extension.aws.resource.ec2 import (
    AwsEc2ResourceDetector,
)
from opentelemetry.sdk.resources import get_aggregated_resources

trace.set_tracer_provider(
    TracerProvider(
        resource=get_aggregated_resources(
            [
                AwsEc2ResourceDetector(),
            ]
        ),
    )
)

Refer to each detectors’ docstring to determine any possible requirements for that detector.

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentelemetry-sdk-extension-aws-1.0.1.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file opentelemetry-sdk-extension-aws-1.0.1.tar.gz.

File metadata

  • Download URL: opentelemetry-sdk-extension-aws-1.0.1.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for opentelemetry-sdk-extension-aws-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3a128fc634057704969315aa11a5fe85ca581588a103632dd8464ab5d61d3729
MD5 383d79b85c93805103923f9d6beea488
BLAKE2b-256 3da063e2171da56c5bcc8860424fca83d59ff061cbea3ee307048b982155bcc5

See more details on using hashes here.

File details

Details for the file opentelemetry_sdk_extension_aws-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: opentelemetry_sdk_extension_aws-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for opentelemetry_sdk_extension_aws-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b615769cf5b3c3be11888c14378358b9494608b47969440b619758a86e498586
MD5 9e652f0589c0b8f29bea5e8973304b5f
BLAKE2b-256 724ca8b362fe2174796ca7c6bc8b10e5d95438b3a716bd2e75f7778cd350edbc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page