Skip to content

fix(api): honor OTEL_PROPAGATORS set after import - #5936

Open
eisen0419 wants to merge 1 commit into
open-telemetry:mainfrom
eisen0419:fix/distro-override-otel-propagators
Open

eisen0419 wants to merge 1 commit into
open-telemetry:mainfrom
eisen0419:fix/distro-override-otel-propagators

Conversation

@eisen0419

Copy link
Copy Markdown

opentelemetry.propagate previously constructed the global text map from OTEL_PROPAGATORS at import time. Because auto-instrumentation imports a distro before calling distro.configure(), setting OTEL_PROPAGATORS inside configure() happened after the default tracecontext,baggage composite was already cached (forcing workarounds such as importlib.reload(propagate)).

This defers loading OTEL_PROPAGATORS until the first get_global_textmap() call (including via extract() or inject()):

  • Explicit set_global_textmap() calls before or after first read still take precedence.
  • Failed entry-point loads are not cached, and importlib.reload(opentelemetry.propagate) continues to reset the cache.
  • Regression tests snapshot and restore both _HTTP_TEXT_FORMAT and OTEL_PROPAGATORS without reloading in tearDown so test order does not leak global state (addressing the review question on opentelemetry-api: honor OTEL_PROPAGATORS set after import #5610).

Fixes #4679

Distros import opentelemetry.propagate and only then set OTEL_PROPAGATORS
from configure(). The global text map was built at import, so that
assignment had no effect. Read the variable on the first
get_global_textmap() call. set_global_textmap() still takes precedence,
and a failed load is not cached.

Fixes open-telemetry#4679
@eisen0419
eisen0419 requested a review from a team as a code owner November 14, 2026 08:09
@eisen0419
eisen0419 force-pushed the fix/distro-override-otel-propagators branch from 5dce65e to 53c7761 Compare November 14, 2026 08:09
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-11-14 08:10 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Distros cannot override the default propagators via OTEL_PROPAGATORS

1 participant