Skip to content

Distros cannot override the default propagators via OTEL_PROPAGATORS #4679

@srprash

Description

@srprash

Describe your environment

OS: MacOS Sequoia
Python version: 3.11
SDK version: 1.33.1
API version: 1.33.1

What happened?

AWS Distro of Openelemetry Python while initializing sets an opinionated list of propagators via the OTEL_PROPAGATORS environment variable to baggage,xray,tracecontext but the actual propagators configured are still the default tracecontext,baggage.

Steps to Reproduce

  1. Create a python virtual environment and install ADOT Python pip install aws-opentelemetry-distro
  2. Create a python script main.py with the following content:
    from opentelemetry import propagate
    
    # print each propagator name
    for p in propagate.get_global_textmap()._propagators:
        print(p.__class__.__name__)
  3. Run the script using the following command
    OTEL_PYTHON_DISTRO=aws_distro \
    OTEL_PYTHON_CONFIGURATOR=aws_configurator \
    opentelemetry-instrument python3 main.py
  4. Among the logs (ignore the export failures) you will see the following propagators which are the default ones from OpenTelemetry SDK:
    TraceContextTextMapPropagator
    W3CBaggagePropagator

Expected Result

The printed propagators should be the following:

W3CBaggagePropagator
AwsXRayPropagator
TraceContextTextMapPropagator

Actual Result

TraceContextTextMapPropagator
W3CBaggagePropagator

Additional context

My RCA is that even before a distro is loaded and initialized, the propagate module is loaded and this module level code is executed which configures the propagators to tracecontext,baggage. By the time the distro sets the OTEL_PROPAGATORS env variable it's already too late.

In ADOT Python, we had to force a reload of the propagate module so that the new propagators are picked up and initialized. aws-observability/aws-otel-python-instrumentation#421

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions