Skip to content
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

Observing issues while adding baggages via 'micrometer-tracing-bridge-otel' #701

Open
mail2imaran opened this issue May 13, 2024 · 3 comments

Comments

@mail2imaran
Copy link

mail2imaran commented May 13, 2024

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.

@marcingrzejszczak
Copy link
Contributor

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.

@mail2imaran
Copy link
Author

mail2imaran commented May 29, 2024

@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

Copy link

github-actions bot commented Jun 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants