Repository navigation
Spring Boot (Webflux): many unrelated http breadcrumbs are recorded with events #1790
Description
Activity
- added 2 commits that reference this issue
on Nov 25, 2021 Based on
ThreadLocal, this issue seems unsolvable.- addedThreadLocalHubProblemIssues caused by Hub being ThreadLocal and no or no easy way to clone the hubIssues caused by Hub being ThreadLocal and no or no easy way to clone the hub
on Feb 7, 2023 We have just released
6.15.0of the Java SDK. If you're on Spring Boot3.0.3+you can giveThreadLocalAccessora try.Here's a copy of the changelog so you know what's required:
Implement ThreadLocalAccessor for propagating Sentry hub with reactor / WebFlux (#2570)- Requires io.micrometer:context-propagation:1.0.2+ as well as Spring Boot 3.0.3+
- Enable the feature by setting sentry.reactive.thread-local-accessor-enabled=true
- This is still considered experimental. Once we have enough feedback we may turn this on by default.
- Checkout the sample here: https://github.com/getsentry/sentry-java/tree/main/sentry-samples/sentry-samples-spring-boot-webflux-jakarta
- A new hub is now cloned from the main hub for every request
We've also fixed a bug for the WebFlux integration (#2580) in this release for older versions of Spring Boot and when not using
context-propagation. In case you give it a try it would be great if you could give us feedback 🙏 .Reacted by kalin-leeClosing this now as it should be resolved (see comment above), feel free to reopen if you run into the problem again.
This is still an issue for our Spring Boot 2 integration.
We could take another stab at it by trying to use
reactor.core.CoreSubscriberandHooks.onEachOperatoras described here. Needs testing whether this is has a lot of impact on performance.Putting this in the backlog but can't say when we'll get to it.
We're currently not planning on adding improved support for Spring Boot 2 as the number of users is declining.
If you need this please give our updated OpenTelemetry integration a try. It might work better here. Here's docs on it: https://docs.sentry.io/platforms/java/guides/spring-boot/tracing/instrumentation/opentelemetry/
Platform:
IDE:
Build system:
Platform installed with:
The version of the SDK:
5.2.4
I have the following issue:
Many (tens or even ~hundred) unrelated http breadcrumbs recorded with events. These breadcrumbs are:
Steps to reproduce:
Actual result:

Screenshot from actual server-running instance
Expected result:
Only a couple of related http breadcrumbs are present
Personal thoughts
Both SentryWebFilter & SentrySpanClientWebRequestFilter use HubAdapter, which uses static Sentry.getCurrentHub() method, which returns ThreadLocal instance of Hub.
It seems like this mechanism may not work correctly with reactive application, which serves requests on a small number of threads, and they are switched frequently.
As far as I know, there is a way of storing arbitrary request-related data in webflux: