Open
Description
Describe the bug
When using Kafka in batch mode, I observed that producer and processor spans are not tied together with the same traceId. However, when in single-record mode, spans are correctly linked under a shared trace context.
This result makes it difficult to achieve proper end-to-end traceability when processing messages in batches — which is a common practice in performance-sensitive systems.
This image shows the result of a test on a sample application
Steps to reproduce
- Configure a @KafkaListener with a ConcurrentKafkaListenerContainerFactory bean.
- Enable batch mode via:
factory.setBatchListener(true);
Expected behavior
Producer and process spans should be tied together with the shared trace context to make proper end-to-end observability as soon as possible.
Actual behavior
- On batch mode, producer and process are not tied together with one traceId, having different trace context.
- On single record mode, produce and process are tied together with one traceId.
Javaagent or library instrumentation version
v2.17.0
Environment
JDK: Eclipse Temurin 21.0.6
OS: Mac OS 15.3.1 (24D70)
Additional context
No response