-
-
Notifications
You must be signed in to change notification settings - Fork 427
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
Clone hub from main hub for every WebFlux request #2567
Clone hub from main hub for every WebFlux request #2567
Conversation
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
b19c118 | 417.94 ms | 478.42 ms | 60.48 ms |
a864e2f | 353.66 ms | 392.94 ms | 39.28 ms |
b300cf4 | 371.66 ms | 401.00 ms | 29.34 ms |
a98c90a | 293.96 ms | 333.90 ms | 39.94 ms |
b548154 | 328.82 ms | 405.74 ms | 76.92 ms |
098ff45 | 273.73 ms | 363.61 ms | 89.88 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
b19c118 | 1.73 MiB | 2.34 MiB | 626.30 KiB |
a864e2f | 1.73 MiB | 2.34 MiB | 626.31 KiB |
b300cf4 | 1.73 MiB | 2.34 MiB | 626.31 KiB |
a98c90a | 1.73 MiB | 2.34 MiB | 626.31 KiB |
b548154 | 1.73 MiB | 2.34 MiB | 626.30 KiB |
098ff45 | 1.73 MiB | 2.34 MiB | 626.30 KiB |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## feat/use-thread-local-accessor-for-webclient #2567 +/- ##
==================================================================================
+ Coverage 80.35% 80.41% +0.06%
- Complexity 4011 4020 +9
==================================================================================
Files 332 332
Lines 15148 15155 +7
Branches 1979 1979
==================================================================================
+ Hits 12172 12187 +15
+ Misses 2197 2189 -8
Partials 779 779
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
…/reactor-with-sentry-continue-or-fresh
…/reactor-with-sentry-continue-or-fresh
*/ | ||
@ApiStatus.Internal | ||
@ApiStatus.Experimental | ||
public static @NotNull IHub getNewHub() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe naming it something like cloneMainHub
or mainHubClone
is better? Because getNewHub
is not self-descriptive (e.g. from the first look it's not clear what's the diff between getCurrentHub and getNewHub)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, didn't like the name either. cloneMainHub
sounds good to me.
I think it’s fine. My only thought would be if we should skip cloning on global hub mode? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, maybe call it withSentryMain/GlobalHub
@ApiStatus.Internal | ||
@ApiStatus.Experimental | ||
public static @NotNull IHub getNewHub() { | ||
return mainHub.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to get a fresh hub cloned from the main hub to not risk leaking data from one request into another. Any static interaction with Sentry on a thread that isn't being wrapped by the whole ThreadLocalAccessor
thing could possibly write to another requests hub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you need more context on where this is used, here's another PR that might help understand: [sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/webflux/SentryWebFilterWithThreadLocalAccessor.java](https://github.com/getsentry/sentry-java/pull/2570/files#diff-d21df3f03432d4f76a5539cb4bf199385dc8c956116371c4144153cde2e73de3)
*/ | ||
@ApiStatus.Internal | ||
@ApiStatus.Experimental | ||
public static @NotNull IHub getNewHub() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, didn't like the name either. cloneMainHub
sounds good to me.
* - having `io.projectreactor:reactor-core:3.5.3+` (provided by Spring Boot 3.0.3+) | ||
*/ | ||
@ApiStatus.Experimental | ||
public static <T> Mono<T> withFreshSentry(final @NotNull Mono<T> mono) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO find better name
#skip-changelog
(modified changelog entry for this chain of PRs instead of having a separate one)
📜 Description
Clone hub from main hub for every WebFlux request
💡 Motivation and Context
If we just use whatever hub is there on the thread, we could leak between requests.
💚 How did you test it?
manually using debugger
📝 Checklist
sendDefaultPII
is enabled.🔮 Next steps