Trace ID leakage in reactive Kafka consumer concatMap operations
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java, kafka
- Domain
- distributed-systems, observability-sre
Research direction
Start with the linked reactive-kafka-consumer reproduction and run it with dd-java-agent versions 1.43.0 and 1.53.0. Compare trace IDs inside sequential concatMap processing with the outer chain and with flatMap. Done means each consumed message keeps its own Kafka-header trace ID throughout concatMap processing, without manual context management.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Java
- Stars
- 737
- Forks
- 361
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 173
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DataDog/dd-trace-java
-
type: feature request
Difficulty 1/5 1-3 hours Newbie friendliness 70/100
DataDog/dd-trace-java#10245 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 62/100
DataDog/dd-trace-java#12608 ·
-
type: bug report
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DataDog/dd-trace-java#12597 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DataDog/dd-trace-java#12540 · 3 comments · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
DataDog/dd-trace-java#12480 ·
All issues in DataDog/dd-trace-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
elastic/gradle-plugins#157 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
cryptomator/hub#497 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
johanhaleby/occurrent#1120 ·