Skip to content

Spring Boot v3.1.0 - Micrometer Tracing Not Working w/ Webflux Projects #30652

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

Closed
joseph-freeman opened this issue Jun 12, 2023 · 6 comments
Closed
Labels
for: external-project Needs a fix in external project status: invalid An issue that we don't feel is valid theme: observability An issue related to observability and tracing

Comments

@joseph-freeman
Copy link

Good morning! I'm running into the similar issue when switching from Spring Cloud Sleuth to Micrometer Tracing. With Sleuth everything just seems to work with Reactor based Spring project. When upgrading our service to Spring Boot 3.1.0 and adding the dependency,

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>

the traceId and spanId are no logging present in the logs. I've also tried using Hooks.enableAutomaticContextPropagation(), that didn't work either. So it seems that when updating to Spring Boot 3.x, we lose the ability for distributed tracing. I've read this post and many others that seemingly tracing is not supported using Spring Webflux. If there's an update on when this will be available to Webflux projects that would great to now.

Spring Boot version: 3.1.0
Micrometer Tracing version: 1.1.1

Here's a link to same project demonstrating the issue:
https://github.com/joseph-freeman/micrometer-tracing-issue

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 12, 2023
@bclozel bclozel self-assigned this Jun 12, 2023
@bclozel bclozel added the theme: observability An issue related to observability and tracing label Jun 12, 2023
@OlegDokuka
Copy link

@joseph-freeman can you please provide an exact reproducer of the problem.

Thanks,
Oleh

@joseph-freeman
Copy link
Author

@OlegDokuka Not exactly sure what I need to provide if the repo I create is not sufficient. When you run the service provided by the link, are you seeing the traceId and spanId in the logs? That's the issue I'm having. Either there's additional configuration necessary to have the traceId and spanId in the logs that's not documented, or I'm not understanding how tracing should be setup with a Spring Boot Webflux project. Can you provide a working example uses Spring Webflux that's logging the trace and span IDs in the logfile?

@bclozel
Copy link
Member

bclozel commented Jun 15, 2023

I've submitted a PR to your sample application.
I took the liberty to remove everything and only keep the essential.

I think your app missed Hooks.enableAutomaticContextPropagation();. Please follow/upvote the dedicated Spring Boot issue spring-projects/spring-boot#34201 if you would like it to be a configuration property or even the default.
I don't see any issue left on the Spring Framework side, so I'm closing this.

Thanks!

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2023
@bclozel bclozel removed their assignment Jun 15, 2023
@bclozel bclozel added status: invalid An issue that we don't feel is valid for: external-project Needs a fix in external project and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 15, 2023
@joseph-freeman
Copy link
Author

@bclozel Thanks for the update. So Micrometer tracing doesn't support logging the trace and span IDs when using Log4j2. That's the only other difference (minus the addition Hooks.enableAutomaticContextPropagation();, which I did try before be nothing work, it looks like the main issue is Log4j2 integration with tracing. locally I added back the log4j2.properties and dependency and it did not work. Works with out it. We heavily use Log4j, should I open another issue in regards to tracing not working when using Log4j2?

@bclozel
Copy link
Member

bclozel commented Jun 15, 2023

I don't think this is a fair assessment. While there is an issue with the log4J setup, the job of context propagation is to ensure that the current observation is available at as a thread local value or in the reactor context. Spring Framework's responsibility is to instrument the infrastructure for observations. Both work here.

Maybe there is an issue with the logging setup that prevents the MDC from working properly? spring-projects/spring-boot#31468 suggests that it requires SLF4J. Have you tried with such a setup?

@bclozel
Copy link
Member

bclozel commented Jun 15, 2023

Just a thought - maybe join the micrometer.io Slack to discuss that with the community ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a fix in external project status: invalid An issue that we don't feel is valid theme: observability An issue related to observability and tracing
Projects
None yet
Development

No branches or pull requests

4 participants