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

Why doesn't Sleuth enable Scope when create Span for Kafka Streams by default? #2343

Closed
lianej opened this issue Mar 11, 2024 · 1 comment
Closed
Labels

Comments

@lianej
Copy link

lianej commented Mar 11, 2024

Hi team,

My project is based on spring-cloud-stream-kafka 3.1.4 and spring-cloud-sleuth 3.0.4 (and zipkin brave).
When I use Sleuth, while also benefiting from tracing context information from slf4j.MDC such as traceId and spanId, it allows me to track logs more easily.

However, I recently found out that when Sleuth collects information about kafka-streams endpoints, it does not update MDC.
This is because Brave only updates MDC when a span is in scope(brave.context.slf4j.MDCScopeDecorator.MDCContext), and Sleuth does not have corresponding support for spring cloud stream kafka; it directly uses the kafka-streams instrument provided by Brave.
As far as I know, none of the instruments provided by Brave simultaneously enable scope when create/get span.

On the other hand, the web instruments (such as org.springframework.cloud.sleuth.instrument.web.servlet.TracingFilter) provided by Sleuth have scope enabled during processing.

Q:

  1. Is it true that Sleuth does not enable Scope when processing Kafka Streams?
  2. (If the answer to 1 is True) Why is Scope not enabled when processing kafka-streams endpoints, but it is enabled when handling Web requests?
  3. Is opening the scope myself a good practice? (through AOP or other means)
@jonatan-ivanov
Copy link
Member

I think this is intentional since you can get multiple messages at that point, which one of them should be chosen for propagating its tracing information?
Also, even if this would be a bug, Sleuth 3.1 reached the end of its OSS support lifetime, you should migrate to the latest Micrometer Tracing (and latest Spring Boot 3.x).

@jonatan-ivanov jonatan-ivanov closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants