dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

Trace ID leakage in reactive Kafka consumer concatMap operations

Open faent opened this issue 4 months ago • 0 comments

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

  1. First message: Trace ID is correctly set (e.g., trace_id=123)
  2. 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

  1. First message: Trace ID is correctly extracted from Kafka headers (e.g., trace_id=123) and maintained throughout the processing chain
  2. 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

faent avatar Oct 16 '25 11:10 faent