AWS SDK extension for OpenTelemetry
Project description
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)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for opentelemetry-sdk-extension-aws-0.24b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e1e25beb330bfbea1e1fe2478c75d1d6ea21573a9f5e2bb41296c533a6e600e |
|
MD5 | d7a278a4b880c254594799171d97f9bc |
|
BLAKE2b-256 | af417cc931eaebeeedeb84897fa6d14cedaa38df339d4356010fd378b2e64a62 |
Hashes for opentelemetry_sdk_extension_aws-0.24b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bc80c2f7d342faa06b38e066b61d9484321e37b1fa43f14c42034ed78536005 |
|
MD5 | beccf9c847f2c974135071866e297c1b |
|
BLAKE2b-256 | e56c2d9c6a1ae5d34a3a45eeb93f727494f3de0f43de6db91fdd6c668c532524 |