dd-trace-java
dd-trace-java copied to clipboard
Trace ID leakage in reactive Kafka consumer concatMap operations
Tracer Version(s)
1.43.0, 1.53.0
Java Version(s)
17.0.15
JVM Vendor
Oracle JDK
Bug Report
When using dd-java-agent's automatic instrumentation with reactor-kafka, trace IDs from the first consumed Kafka message incorrectly leak into subsequent messages within concatMap operators. No manual span creation or context management is being used - this occurs purely with automatic instrumentation.
Actual Behavior
- First message: Trace ID is correctly set (e.g., trace_id=123)
- Second message: The outer reactive chain has a new trace ID (e.g., trace_id=456) - this is correct Operations inside concatMap still show the first message's trace ID (trace_id=123) - here expected trace_id=456
Issue does not occur with flatMap - only with concatMap (sequential processing)
Is manual context propagation required for concatMap scenarios, or is this a bug in automatic instrumentation?
Expected Behavior
- First message: Trace ID is correctly extracted from Kafka headers (e.g., trace_id=123) and maintained throughout the processing chain
- Second and subsequent messages: Each message's trace ID from its Kafka headers is properly extracted and maintained throughout the entire chain processing, independent of previous messages
Reproduction Code
https://github.com/faent/reactive-kafka-consumer/tree/main