Skip to content

Trace ID leakage in reactive Kafka consumer concatMap operations #9775

@faent

Description

@faent

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugBug report and fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions