Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The trace IDs are not being propagated. #3698

Open
fleszarnatalia opened this issue Jan 5, 2025 · 2 comments
Open

The trace IDs are not being propagated. #3698

fleszarnatalia opened this issue Jan 5, 2025 · 2 comments

Comments

@fleszarnatalia
Copy link

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.

@artembilan
Copy link
Member

I think with 3.3.7 you mean Spring Boot version.
Spring for Apache Kafka for that one is 3.2.6.

I don't think the producer creating phase is supposed to be included into some trace.
Usually that happens during Spring application startup.
However, I agree that producing and consuming has to be maintain the same trace.
That's exactly the whole point of the distributed tracing.

Would be great if you could share with us a simple project where we can reproduce the problem.

Thank you!

@artembilan
Copy link
Member

Please, take a look into the sample I propose for the project code base: #3699.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants