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
Regression in Webflux test when explicitely providing tracing headers #1846
Comments
Is this bug report only about tests and
|
What are the headers that are being passed? |
I've tried the B3 headers as well as the newer ones (localhost:9095 is a Spring Cloud Gateway instance):
The logs (or MDC) does not show the "explicit" values but new traces like fa2ed5b4165d32e9. Furthermore, also the downstream service that is called by the gateway receives the trace IDs generated by the gateway instead of the manually passed ones:
Note that the |
|
Gosh... indeed... yeah... it's working as expected with proper values... seems like I've fooled myself during testing ;-) |
No problem, glad that things are working fine :) |
Hello, |
Actually there are no new
you're saying that you send (the ids are just a sample)
and in the gateway those headers are ignored and traceid and spanid are set to other values? |
I don't think 1 and 2 are valid values. Can you set propert values there? E.g.
|
Interestingly it does not work with ID values smaller than 10. For me it is also not working with Update: hehe, simultaneous post :) |
I have no idea what is the thing that you're returning. Are values in the logs wrong? Is the trace data propagated properly? What do the Sleuth logs say? |
Let me try to summarize what I'm doing when I execute my test. The first step is a call using the webTestClient where I set the headers: At this step, the spandId set in the header is "a2fb4a1d1a96d312" Then, when I execute this test in debug mode, I'm able to visualize the content of the TraceContext instance (import org.springframework.cloud.sleuth.TraceContext) My understanding is that the value of the spanId is never propagated to the TraceContext. If you need some sleuth log, I have to setup logging in the reproducer. I can do it in the meantime. |
Wait a second - the trace context looks ok, the spanid is the child of the |
Well, I'm calling only one service from my test and my understanding is that the spandId and parentId would be equal to the ones I'm setting in the header. Am I misunderstanding how the traceContext should be instanciated? |
It depends on what you're calling. What does happen properly is that on the client side the request headers were set properly and the trace context was successfully propagated. I have no idea what your controller does and how it looks like. |
The controller does nothing more than what I shared in the reproducer : Controller link here the steps are:
|
Most likely that's a component somewhere in the reactor instrumentation that is creating a child span. I don't see a bug here nor a regression. The context is properly propagated. |
What confuses me is that it was the same issue in the following ticket: pring-projects/spring-cloud-sleuth#1507 In older versions of spring boot, the test in the reproducer actually passed (that's why I consider it a regression because the test passed until we move to Spring boot 2.4). The reproducer is a simple extract of an automated test of our project so we have detected that the behaviour around the propagation of the spanId/parentId seems different |
Ok I'll triple check this when I have time. Thanks for the reproducer. |
I'm sorry but I can't import the project to my IDE. Can you rewrite the sample to Java and Maven? |
Hello @marcingrzejszczak, I'm going to take a look to convert it today in java/maven on a separate brach |
@marcingrzejszczak You can find the converted reproducer at the following location : here |
I know what the problem is. Brave has the notion of As a workaround what you can do is create your own bean like this @Bean
BaggagePropagation.FactoryBuilder myBaggagePropagationFactoryBuilder() {
return BaggagePropagation.newFactoryBuilder(B3Propagation.newFactoryBuilder().injectFormat(B3Propagation.Format.SINGLE_NO_PARENT).build());
} and then you'll override the faulty composite one that I'll try to fix asap. |
Describe the bug
Re-opening spring-projects/spring-cloud-sleuth#1507 because it looks like there is a regression linked to this bug.
Reminder of the encountered issue:
Once using Sleuth and injecting Tracing headers in a WebTestClient I was able to retrieve them in Reactor's context later on like this :
When comparing spanId and parentId present in the org.springframework.cloud.sleuth.TraceContext object, it appears that values are different than the spanId and parentId set in the headers.
Spring libraries versions used to reproduce this issue:
Sample
Sample available here
The branch 2021 contains latest changes to reproduce the issue with latest libraries (project forked from the initial reproducer)
The issue can be reproduced by executing the test com.spring.reproducer.spring.test.sleuth.reproducer.TracingResourceTest
The text was updated successfully, but these errors were encountered: