Open mail2imaran opened 5 months ago
Hey, thank you for the sample.
I see that in your code you're doing commonLogs.forEach(tracer::createBaggageInScope);
which is invalid. You're opening scopes and never closing them.
We've provided a different way of working with baggage in reactor. Check this section of the docs for more info.
@marcingrzejszczak I tried that as well, even that didn't help, traceId is still the same across two requests.
check out baggageClosure
branch
https://github.com/mail2imaran/spring-boot-3-tracing-test/tree/baggageClosure
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.
Background : I am trying to add a few common logging attributes in TraceContext scope as baggages in WebFilter, so that whenever we log any statement, we don`t have to add those common attributes explicitly, these should be added in logs through micrometer-tracing library.
Issue : Adding baggages in context leading to abnormal behavior of Otel-Tracer library. TraceId & baggages are not being cleared from thread for subsequent requests. Whenever a new HttpRequest is received by same thread, old traceId and all old baggages can be seen.
Observation : Same piece of code is working well with
micrometer-tracing-bridge-brave
Libraries in use: - SpringBoot : 3.2.3 micrometer-core:1.12.3 micrometer-observation:1.12.3 micrometer-tracing:1.2.3 micrometer-tracing-bridge-otel:1.2.3
Piece of code adding baggages : -
Map<String, String> commonLogs = getCommonLogMap(exchange); commonLogs.forEach(tracer::createBaggageInScope);
Git repo for the sample project : https://github.com/mail2imaran/spring-boot-3-tracing-test/blob/main/src/main/java/some/sample/filter/LogEntryExitFilter.java
Please refer to ReadMe.