Repository navigation
Description
Description
When FlowIdSpanDecorator is configured with propagateFlowId = true, it is
expected to forward the current OpenTelemetry baggage Flow ID to the downstream
HTTP service using the X-Flow-ID header.
The decorator previously called arguments.withHeader(...), but
RequestArguments is immutable. withHeader(...) returns a new request
instance; it does not modify the original one. Because that returned instance
was discarded, OpenTelemetryPlugin later executed the original request
without the Flow ID header.
The Flow ID was still recorded as a tracing span attribute, which makes the
problem easy to miss: tracing looks correct locally, but the downstream service
does not receive the correlation header.
Expected Behavior
With Flow ID propagation enabled and a Flow ID in the current OpenTelemetry
baggage, the outgoing request should contain exactly the propagated value:
X-Flow-ID: flow-id-valueWhen propagation is disabled, or no Flow ID exists in baggage, no X-Flow-ID
header should be added.
Actual Behavior
With the current implementation, the outgoing request does not contain an
X-Flow-ID header even when propagation is enabled and baggage contains a
Flow ID.
OpenTelemetry baggage contains flow_id
↓
FlowIdSpanDecorator calls RequestArguments.withHeader(...)
↓
The returned immutable request is discarded
↓
OpenTelemetryPlugin executes the original request
↓
The downstream service never receives X-Flow-ID
Possible Fix
Add a request-decoration step that returns RequestArguments:
- Add a default
decorateRequest(RequestArguments)method toSpanDecorator
that returns the unchanged request. This keeps existing decorators fully
compatible. - Let
CompositeSpanDecoratorpass the request returned by each decorator to
the next decorator. - Let
FlowIdSpanDecoratorreturnarguments.withHeader(...)only when
propagation is enabled and baggage has a Flow ID. - Execute the final decorated request from
OpenTelemetryPlugin.
Steps to Reproduce
- Configure
OpenTelemetryPluginwithnew FlowIdSpanDecorator(true). - Store a Flow ID in the current OpenTelemetry baggage.
- Execute a Riptide request through the plugin.
- Inspect the
RequestArgumentsreceived byRequestExecution, or inspect
the request at the downstream server.
var plugin = new OpenTelemetryPlugin(
openTelemetry,
new FlowIdSpanDecorator(true));
var baggage = Baggage.builder()
.put(ExtensionAttributes.FLOW_ID.getKey(), "flow-id-value")
.build();
try (var scope = baggage.storeInContext(Context.current()).makeCurrent()) {
plugin.aroundAsync(execution).execute(arguments).join();
}Before the fix, the captured outgoing request has no X-Flow-ID header.
Context
Flow IDs are used to correlate work across service boundaries. Without the
header, a downstream service cannot associate an incoming request with the
upstream request trace. This makes debugging distributed requests and tracing
their full path more difficult.
The fix is protected by tests for:
- Flow ID present and propagation enabled.
- Flow ID present and propagation disabled.
- No Flow ID in baggage.
- Multiple decorators, ensuring each receives the request returned by its
predecessor.
Environment
- Version used: Riptide
5.1.3-SNAPSHOT - Java version: JDK
21.0.12. - Operating system: Windows.
TestRunBeforeBug
TestRunWithBug
TestRunAfterBugFix
Activity
fatroom commentedon Nov 3, 2026
This statement is not correct. Check the rules: https://opensource.zalando.com/restful-api-guidelines/#233
Relevant quote:
Note: API-Clients must provide Flow-ID when calling a service or producing events. If no Flow-ID is provided in a request or event, the service must create a new Flow-ID.
Additionally: for generation of new X-Flow-ID value use span.getSpanContext().getTraceId();
@visheshupadhyay can you update your fix according to this info?
visheshupadhyay commentedon Nov 4, 2026
Thanks for the clarification and feedback @fatroom ,
I'll review the referenced guidelines and the current implementation to better understand the expected behavior. I'll also look into the suggested test separation and make the necessary changes based on my findings.
Appreciate your guidance!
visheshupadhyay commentedon Nov 4, 2026
I have updated the implementation locally so every outgoing request receives an X-Flow-ID.
This keeps the outgoing header and the span flow_id attribute aligned, while ensuring clients always provide a Flow ID as required by the guidelines.
Before I push the update, @fatroom could you please confirm that this is the intended meaning of propagateFlowId=false? I’ll wait for your guidance in case you prefer a different behavior.
fatroom commentedon Nov 4, 2026
This logic is mostly correct. I would as well recommend to take care about following situation:
getSpanContext() might return invalid context in case when sdk isn't available. For this context getTraceId will always provide constant value, defeating purpose of the X-Flow-Id. the validity of context can be verified with isValid() method. For such cases X-Flow-Id should be generated randomly.
propagateFlowId flag should be dropped from code.
visheshupadhyay commentedon Nov 4, 2026
Thanks for the clarification. When you say to drop propagateFlowId, do you mean only from the new OpenTelemetry FlowIdSpanDecorator flow, or should we also remove the existing public Spring configuration properties (tracing.propagate-flow-id / telemetry.propagate-flow-id) and the legacy FlowHttpRequestInterceptor behavior?
fatroom commentedon Nov 4, 2026
Only telemetry version and corresponding property. Tracing should stay as is.
visheshupadhyay commentedon Nov 5, 2026
Thanks for clarifying the intended scope.
I updated the implementation so that the existing
Tracing.propagateFlowIdbehavior remains unchanged. The flag is now removed only from the Telemetry/OpenTelemetry path.The final Flow ID selection is:
I also added coverage for baggage precedence, valid and invalid contexts, UUID fallback, and ensuring the outgoing X-Flow-ID value matches the span attribute.
Validation completed successfully for:
riptide-opentelemetrytestsriptide-httpclienttestsriptide-opentelemetryandriptide-spring-boot-autoconfigurePlease let me know if you would like any further adjustments.
fatroom commentedon Nov 18, 2026
After internal discussion, we decided that logic from rest guidelines should be left to the caller, not the http client in this case.
But initial with missing headers is fixed in #1905
visheshupadhyay commentedon Nov 18, 2026
Thanks for the update and for clarifying the architectural direction.
I understand the decision to keep HTTP header propagation within a dedicated OpenTelemetry propagator and leave Flow ID generation policy to the caller.
I appreciate the review and guidance throughout the investigation. Glad the original issue is being addressed in #1905!