spring-kafka
spring-kafka copied to clipboard
The trace IDs are not being propagated.
In what version(s) of Spring for Apache Kafka are you seeing this issue? "3.3.7"
Describe the bug
When enabling tracing in Spring Kafka using the following configuration:
spring:
kafka:
template:
observation-enabled: true
listener:
observation-enabled: true
the trace IDs are not being propagated.
Description The trace ID changes unexpectedly across different Kafka producer and consumer operations. Below is a sample log output demonstrating the issue:
2025-01-05T19:23:49.726+01:00 INFO 72749 --- [sample-service] [nio-8080-exec-1] [4b7ede1e7858060aeac5ffec1685171d-b03b1a50e75f9d99] c.b.b.c.g.ConfigurationsService 2025-01-05T19:23:49.922+01:00 INFO 72749 --- [sample-service] [ntainer#0-0-C-1] [28838532a77fd955681f83fbb0171a6c-134cd44f90cdb7ee] c.b.c.c.ConfigurationsConsumer
Notice the trace IDs:
[4b7ede1e7858060aeac5ffec1685171d-49e46abd74e60589] during producer initialization. [28838532a77fd955681f83fbb0171a6c-134cd44f90cdb7ee] during consumer message processing. The trace IDs do not remain consistent for operations that should belong to the same trace.
To Reproduce
Enable tracing with the configuration shown above. Perform a Kafka producer operation, followed by a consumer operation. Observe the logs and note the changing trace IDs.
Expected behavior
The trace ID should remain the same throughout the lifecycle of a trace, including producer creation, message publishing, consumer message processing, and downstream operations.