Skip to content

BaggageTextMapPropagator#inject should use the passed ContextΒ #1617

Closed

Description

@shakuzen

BaggageTextMapPropagator#inject(Context, C, TextMapSetter) ignores the Context it is given. It gets the baggage to inject from BaggageManager#getAllBaggage(), i.e. from the current context (and the current trace context), instead of from the passed Context.

This is the inject side of #1163, which was fixed for extract in #1174. OpenTelemetry's own propagators, such as W3CBaggagePropagator, only use the passed Context.

When it matters

OtelPropagator#inject passes a Context built from Context.current(), so for the Micrometer Tracing Propagator the passed Context and the current context have the same baggage. It matters when BaggageTextMapPropagator is called through OpenTelemetry's ContextPropagators with a Context that is not the current one, for example by OpenTelemetry instrumentation when the propagator is registered with the OpenTelemetrySdk (Spring Boot does this).

With W3CBaggagePropagator and BaggageTextMapPropagator (remote field foo) in one composite propagator:

Call foo header baggage header
inject(ctx with foo=bar) while foo=other is current other foo=bar
inject(ctx with foo=bar) with nothing current not set foo=bar
inject(Context.root()) while foo=bar is current bar not set

In the first case the two headers disagree. When both propagators extract on the receiving side, BaggageTextMapPropagator runs last and prefers the carrier value (#1172), so other wins.

Behavior change

After the fix, baggage set with the deprecated BaggageManager#createBaggage(String, String) or Baggage#set(...) without making it current will no longer be injected as remote fields by OtelPropagator. That baggage is stored with the trace context but is not in the current context, and it is not injected in the W3C baggage header either.

Activity

  1. added this to the 1.8.0-RC1 milestone on Oct 20, 2026
  2. modified the milestones: 1.8.0-RC1, 1.8.x on Oct 20, 2026
  3. changed the title [-]BaggageTextMapPropagator#inject ignores the passed Context[/-] [+]BaggageTextMapPropagator#inject should use the passed Context[/+] on Oct 22, 2026
  4. added
    release notesNoteworthy change to call out in the release notes
    performanceIssues related to general performance
    on Oct 22, 2026
  5. added 3 commits that reference this issue on Oct 28, 2026
    c18e138
    bbd94a7
    2eafff3
  6. modified the milestones: 1.8.x, 1.8.0-RC2 on Oct 28, 2026
  7. added a commit that references this issue on Oct 28, 2026
    cc9207b
  8. shakuzen commented on Oct 28, 2026

    @shakuzen
    MemberAuthor

    Added details to the 1.8 migration guide.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA general bugmodule: bridge-otelperformanceIssues related to general performancerelease notesNoteworthy change to call out in the release notes

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions