opentelemetry-python-contrib/sdk-extension/opentelemetry-sdk-extension...
Jonathan Lee 032d6c67be
AWS X-Ray Remote Sampler Part 1 - Initial Classes and Rules Poller Implementation (#3366)
* remote sampling - initial classes and rules poller

* run generate-workflows and ruff

* add component owner for aws sampler, run lint

* move sampler into aws sdk-extensions

* move sampler tests to trace dir, update otel api/sdk deps, update changelog

* move mock_clock into tests dir

* update component owners for sdk-extension-aws

* ruff and lint

* address comments

* make sampler implementation internal until completion, update tests to not make http requests

* remove use of Optional, restore README of the package

* remove unused clock and client_id

* Update component_owners.yml

* Update CHANGELOG.md

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2025-08-25 14:57:48 +02:00
..
benchmarks/trace Move benchmarks outside of tests directory (#2670) 2024-07-09 17:17:00 -06:00
src/opentelemetry/sdk/extension/aws AWS X-Ray Remote Sampler Part 1 - Initial Classes and Rules Poller Implementation (#3366) 2025-08-25 14:57:48 +02:00
tests AWS X-Ray Remote Sampler Part 1 - Initial Classes and Rules Poller Implementation (#3366) 2025-08-25 14:57:48 +02:00
CHANGELOG.md Update opentelemetry-sdk-extension-aws version to v2.2.0 (#3149) 2024-12-24 15:59:31 +01:00
LICENSE fix: revert modifications to Apache license (#2429) 2024-04-22 13:23:38 -05:00
MANIFEST.rst Add SDK Extension for Compatibility with AWS X-Ray 2020-11-09 14:51:30 -08:00
README.rst Move AWS X-Ray Propagator into its own package (#720) 2021-10-12 15:44:03 +00:00
benchmark-requirements.txt Move benchmarks outside of tests directory (#2670) 2024-07-09 17:17:00 -06:00
pyproject.toml AWS X-Ray Remote Sampler Part 1 - Initial Classes and Rules Poller Implementation (#3366) 2025-08-25 14:57:48 +02:00
test-requirements-0.txt AWS X-Ray Remote Sampler Part 1 - Initial Classes and Rules Poller Implementation (#3366) 2025-08-25 14:57:48 +02:00
test-requirements-1.txt AWS X-Ray Remote Sampler Part 1 - Initial Classes and Rules Poller Implementation (#3366) 2025-08-25 14:57:48 +02:00

README.rst

OpenTelemetry SDK Extension for AWS X-Ray Compatibility
=======================================================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opentelemetry-sdk-extension-aws.svg
   :target: https://pypi.org/project/opentelemetry-sdk-extension-aws/


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`.

.. code-block:: python

    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 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`:

.. code-block:: python

    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
----------

* `OpenTelemetry Project <https://opentelemetry.io/>`_
* `AWS X-Ray Trace IDs Format <https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-traceids>`_
* `OpenTelemetry Specification for Resource Attributes <https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions>`_