Fix W3C baggage header not propagated on outgoing WebClient (Reactor Netty) requests#11512
Draft
dougqh wants to merge 1 commit into
Draft
Fix W3C baggage header not propagated on outgoing WebClient (Reactor Netty) requests#11512dougqh wants to merge 1 commit into
dougqh wants to merge 1 commit into
Conversation
…requests CaptureConnectSpan captured only the active span into the Reactor context at subscription time, discarding the full Datadog Context (which carries baggage). TransferConnectSpan then called captureSpan(span) on the Reactor I/O thread where no Datadog scope is active, so the resulting continuation held a context of just the span — no baggage. HttpClientRequestTracingHandler.injectContext(current(),…) therefore found no Baggage entry and skipped the baggage header. Fix: CaptureConnectSpan now also stores Context.current() (the full context including baggage) into the Reactor context alongside the span. TransferConnectSpan uses the new captureSpan(AgentSpan, Context) overload to build the continuation from that captured context, so baggage is carried across the async boundary and injected correctly. The new overload is wired through AgentTracer, TracerAPI, CoreTracer, and ContinuableScopeManager. Fixes: #11510 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CaptureConnectSpanstored onlyactiveSpan()into the Reactor context at subscription time, discarding the full DatadogContext(which carries W3C baggage).TransferConnectSpanthen calledcaptureSpan(span)on the Reactor I/O thread where no Datadog scope is active. The resulting continuation held a context of just the span — no baggage.HttpClientRequestTracingHandlerthen calledinjectContext(current(), …)andBaggagePropagator.inject()found noBaggageentry, so thebaggageheader was silently skipped.Fix:
CaptureConnectSpannow also storesContext.current()(the full context including baggage) into the Reactor context alongside the span.TransferConnectSpanuses a newcaptureSpan(AgentSpan, Context)overload to build the continuation from the captured context, so baggage crosses the async boundary and is injected correctly.The new overload is wired through
AgentTracer,TracerAPI,CoreTracer, andContinuableScopeManager.Trace headers (
traceparent,x-datadog-*) were unaffected because they come from the span object's trace context, not the thread-local baggage — this explains why those worked whilebaggagedid not.Fixes #11510
Test plan
reactor-netty-1.0module asserting that abaggageheader set on the server side is forwarded on the outgoing WebClient request./gradlew :dd-java-agent:instrumentation:reactor-netty-1.0:testLabels
inst:reactor-nettytype:bugtag:ai generated🤖 Generated with Claude Code