-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
WebClient toBodilessEntity loses tracing context in Spring WebFlux 3.0.5 #30273
Comments
Hello @davidmelia , thanks for raising this issue. The workaround you're sharing is not a workaround in my opinion: this merely enables the context propagation for ThreadLocal - here you should see the tracing context for the HTTP server observation, which is still ongoing at that stage since this is being executed within a web controller. Am I missing something? |
I don't quite follow you but we use trace IDs in production to log trace requests. I expect the server trace ID to be propagated through the stack. Using Spring Cloud Sleuth this was the case and the above example preserved the 'tid'. After upgrading to Spring Webflux 3 I can see trace IDs disappearing and I have narrowed down to the use of toBodilessEntity. This is either a bug OR WebFlux users who use enableAutomaticContextPropagation should not use toBodilessEntity as it wipes out log trace IDs. |
Sorry, I misunderstood the issue - I thought this was about the client trace, not about the server trace. Let me have a look into this. |
I had a deeper look and I did reproduce the problem. @davidmelia I've modified your sample application to ensure that the current Observation is in the reactor context right after the
This change is available in my fork. Tagging @chemicL to let him know 👍 |
@bclozel thanks for letting me know. Actually, the latest changes in Reactor don't really fix the reported issue. The fact that you introduced This helps as the server The difference between
vs
I'm not yet certain why delivering the entity via the body processing passes the
|
Reopening so we can investigate. This could be a Framework, Reactor Core or Reactor Netty issue. |
The previous suggestion is incorrect, it has nothing to do with using The reason for the different behaviour is the fact that upon termination, in case of
The case in
My current understanding is that the signals delivered from reactor-netty need to always pass a context restoring Subscriber. Whether reactor-netty should add such protection is debatable. I'm also unsure whether reactor-core should do it - we recently introduced protection against foreign The signal to the WebClient's |
Here's a minimal reproducer for the issue:
With the
In case of the commented lines ( For In this case, we treat the For The default connector for reactor-netty deals with reactor types, which assume to be aware of When any signal is delivered as a result of Netty handling, it should be handling the One way to do it would be to implement the restoration in reactor-netty. Another would be to wrap the result with a IMO, reactor-netty should implement this restoration. If someone deals with reactor-netty's |
Hi guys, any more movement on this? Is this something we will just live with by adding Thanks |
@davidmelia we brainstormed on this and the course of action is that we intend do handle this in reactor-core: reactor/reactor-core#3478. Once this work is ready, depending on whether other projects need to do anything special, we'll create more issues. reactor/reactor-core#3468 contains the current roadmap for the context-propagation effort related to the |
I'm closing this issue in favor of the reactor issues listed above. We'll reopen this if something needs to be done here. |
So
I have tried this but with no success: cc @chemicL
|
@agorbachenko I don't have the context about what you are doing in your application around this code. Please create a minimal reproducer and I can try to offer my help via the Micrometer Slack, where this conversation started. Using |
For those coming to this issue, reactor-core 3.6.0 brings a solution to it. The problem is described in our blog post. |
Hi,
I'm diagnosing a production Spring WebFlux 3.0.5 bug where certain requests are losing their tracing context and I've narrowed this down to the following (example https://github.com/davidmelia/spring-cloud-function-zipkin/tree/bodiless_entity_bug_
where toBodilessEntity loses the tracing context. N.B. I am taking advantage of Hooks.enableAutomaticContextPropagation();
The work around is
I assume toBodilessEntity should keep the trace context?
Thanks
The text was updated successfully, but these errors were encountered: