-
Notifications
You must be signed in to change notification settings - Fork 783
Traces missing/changed with WebFluxSleuthOperators.withSpanInScope in cloud-gateway #2237
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
Can you check the latest snapshots (3.1.6-SNAPSHOT) cause this should be fixed by a6e1dcb |
Hello @marcingrzejszczak your quick reply is much appreciated. can you please share maven repo for snapshot (3.1.6-SNAPSHOT), so that I can point it from my project. |
Sure
|
Hello @marcingrzejszczak As suggested, we tried with Used 3.1.6-SNAPSHOTApplication log |
Is this using the queue decorator wrapping? |
If I understand you correctly, you taking about what value is set for |
Please try turning on the on queue wrapping and try again |
We tried with But we are not very comfortable with the usage of queue decorate because it claim low performance impact. However Also we did some test few days back with all decorators, here is our observation with different decorators
With above result we can say that |
For integrity of Tracing and low performance impact, we are looking to go with @marcingrzejszczak what is your view on this. |
@OlegDokuka is working on a solution that should fix it for future versions of Reactor. Until now we have introduced changes in Sleuth Reactor integration that should fix this problem. Can you check the latest snapshots to see if the decorate_on_each option works better for you now with SC Gateway? |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Thanks @marcingrzejszczak for the feedback. We are in process to migrate to spring boot 3, do you think this will also fix this issue, as it use |
We are working on that. |
With Spring Cloud Sleuth 3.1.6 this should be fixed when using queue wrapping mechanism |
Describe the bug
Version details
spring-cloud-gateway: 3.1.4
spring-cloud-sleuth: 3.1.4
Issue
Recently we identified an issue in cloud-gateway where we found traces and spans are missing in log at multiple places. After investigation we found its due to
spring.sleuth.reactor.instrumentation-type
is explicitly set tomanual
for cloud-gateway and this mode suggest to handle tracingContext manually by usingWebFluxSleuthOperators
, as given in this document and issueThis issue is not appearing with other spring boot applications because
spring.sleuth.reactor.instrumentation-type
is set to its default valueDECORATE_ON_EACH
, which guarantee to wraps every Reactor operator in a trace representation.We changed our code as per suggested by document and wrap all our loggers within
WebFluxSleuthOperators.withSpanInScope
, as given below.and we found very less occurrence of missing traces and spans in logs :)
But after deep analysis of log we found, traceId and spaneId are different at some places (for the single route), where we calling some external api (through RetrofitClient) from cloud-gateway, and I believe its due missing tracingContext at the time of external call and due to this new traceId and spanId get generated. This behavior is misleading for someone who using tools like kibana to search log based on traceId, additionally in some of the cases traceId and spanId are still missing for the libraries by spring-cloud-gateway
As we used
WebFluxSleuthOperators
in our application, but we didn't have any control over external libraries like RetrofitClient, so how we need to handle such scenario.Sample
Below screenshot where we are getting different traceId and spanId for single route call.
Below screenshot where we are not getting any traceId and spanId
Just want to add that by changing
spring.sleuth.reactor.instrumentation-type
toDECORATE_ON_EACH
everything works as expected.The text was updated successfully, but these errors were encountered: