Skip propagating empty W3C tracestate header on outbound spans - #14499
Open
davidefrageri wants to merge 1 commit into
Open
Skip propagating empty W3C tracestate header on outbound spans#14499davidefrageri wants to merge 1 commit into
davidefrageri wants to merge 1 commit into
Conversation
|
Thanks for the contribution! Unfortunately we can't verify the commit author(s): Davide Frageri <d***@d***.h***.t***.it>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated. |
Co-authored-by: Cursor <cursoragent@cursor.com>
davidefrageri
force-pushed
the
fix/empty-tracestate-header-propagation
branch
from
May 27, 2026 15:15
fa82776 to
5e12ba0
Compare
|
Thanks for the contribution! Before we can merge this, we need @davidefrageri to sign the Salesforce Inc. Contributor License Agreement. |
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
OpenTelemetryTraceIdUtils#getDistributedTraceContextunconditionally adds thetracestateentry to the distributed-trace context, even when the encodedTraceStatereturned byW3CTraceContextEncoding.encodeTraceStateis the empty string. When that map is later applied to an outbound HTTP request (for example by thehttp:requestoperation propagator) the runtime emits a bare tracestate header on the wire.Per the W3C Trace Context specification,
tracestatemust contain at least one list-member, so an empty header isnon-conformant. Several intermediaries (some L7 load balancers, API gateways and OTLP collectors we hit in production) reject the whole request with
400 Bad Requestwhen they encounter it, which breaks downstream calls madefrom a Mule flow that does not happen to have any vendor entries on its trace state.
What's changed
OpenTelemetryTraceIdUtils#getDistributedTraceContextnow:isAddMuleAncestorSpanIdcheck).tracestatekey into the returned context map when the encoded value is non-null and non-empty.The
traceparentheader is still emitted unconditionally — only the optionaltracestatecompanion is suppressed when it would otherwise be empty. The inbound side (MutableMuleTraceState.getMutableMuleTraceStateFrom) already treats a missing or emptytracestateentry as "no remote trace state", so this is symmetric and does not change how propagated state is parsed.Steps to reproduce (before the fix)
http:requestand OpenTelemetry tracing enabled (mule-opentelemetry-module/ built-in tracer exporter).TraceState(the common case for a freshly created root span).tcpdump/mitmproxy/the target service's access log.tracestate:header alongsidetraceparent: 00-….After the fix only the
traceparentheader is sent in that scenario; once a non-emptyTraceStateis present (incoming W3Ctracestatewith vendor entries, or the Mule ancestor span id added viaisAddMuleAncestorSpanId) the header is emitted as before.Scope of the change
modules/tracing/mule-tracer-exporter-impl/.../OpenTelemetryTraceIdUtils.java