-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Missing tracing information after upgrading to Spring Boot 3 with Micrometer tracing #31993
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
Comments
Thanks for reaching out with a detailed sample.
We've certainly tried to make the upgrade as easy as possible. The intent was also to solve all the underlying issues with Sleuth's approach: overhead, over-instrumentation, etc.
I don't think this is as simple as that. Maybe the guide can be improved as a result of our conversation here. Calling When automatic context propagation is enabled, Project Reactor automatically captures the context for blocking operators:
I think this makes sense because unlike
This is already done (see spring-projects/spring-boot/issues/34201). You can opt in with the following configuration property in your sample application: spring:
reactor:
context-propagation: auto Note that the setup in the sample application is not ideal, using a
I'm not sure I understand. If you enable automatic propagation it will be taken care of for you in most cases. If you wonder about capturing the context for those I don't think there is anything actionable in Spring Framework right now, so I'd suggest getting in touch with the Micrometer team if you think the migration guide could use some updates. You can also reach out to the Reactor team about the Thanks! |
@bclozel thanks for the detailed reply, will follow up with the respective teams |
Thank you @bclozel for covering so many aspects. I added a few points in the reactor-core issue to further clarify the motivation for the current state of affairs. |
Context
After upgrading to Spring Boot 3, we had to switch our tracing library from spring cloud sleuth to micrometer tracing (referring to the migration guide https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide).
Expected Behavior
We expect that the migration from sleuth to micrometer should be smooth, providing good backward compatibility. In particular, as the project uses reactive programming extensively, tracing information such as traceId should be preserved in SL4J logs along the reactive chain.
Actual Behavior
Despite already calling
Hooks.enableAutomaticContextPropagation()
, reactive chain involving reactive web client fails to preserve tracing information such as traceId in SLF4J logs when the chain is invoked using.subscribe
. The migration guide clearly suggests that callingHooks.enableAutomaticContextPropagation()
is enough.Reproductor
I have prepared a reproducer (spring boot test) to demonstrate the potential bug. Please refer to https://github.com/jhengy/my-simple-springboot-app/tree/demo-context-propagation
Follow up questions
.contextCapture()
before.subscribe
explicitly in all the reactive chains. This seems too repetitive and it was expected that migration from sleuth to micrometer should involve minimall changes to the business code. Also, there seems to be a limitation to using.contextCapture()
: it only captures context for logs in the upstream, but not downstream. Is there a better and more convenient way (perhaps some kind of global setting) go about doing this?Hooks.enableAutomaticContextPropagation()
with.contextCapture()
?Thank you.
The text was updated successfully, but these errors were encountered: