Repository navigation
Description
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
Add benchmark for OtelPropagator#inject
[-]BaggageTextMapPropagator#inject ignores the passed Context[/-][+]BaggageTextMapPropagator#inject should use the passed Context[/+]Deprecate BaggageTextMapPropagator constructor taking BaggageManager
Inject baggage of the passed Context in BaggageTextMapPropagator
Add benchmark for OtelPropagator#inject
Deprecate BaggageTextMapPropagator constructor taking BaggageManager
Inject baggage of the passed Context in BaggageTextMapPropagator (#1618)
shakuzen commentedon Oct 28, 2026
Added details to the 1.8 migration guide.