Avoid forking rootScopes for Reactor if current thread has NoOpScopes#4793
Merged
Avoid forking rootScopes for Reactor if current thread has NoOpScopes#4793
rootScopes for Reactor if current thread has NoOpScopes#4793Conversation
adinauer
commented
Oct 9, 2025
| } | ||
|
|
||
| @ApiStatus.Internal | ||
| public static boolean hasScopes() { |
Member
Author
There was a problem hiding this comment.
An alternative to exposing this could be to have an overload of Sentry.getCurrentScopes() that could e.g. have a bool parameter to specify whether to fork rootScopes or just return NoOpScopes if there's nothing there yet.
Member
There was a problem hiding this comment.
Hmm yeah I would prefer this option, however for the purpose of the release I'm fine to go with this for now
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 7314dbe | 437.83 ms | 505.64 ms | 67.81 ms |
| dcc6bbf | 382.58 ms | 462.13 ms | 79.54 ms |
| a5ab36f | 316.83 ms | 394.54 ms | 77.71 ms |
| 27d7cf8 | 314.17 ms | 347.00 ms | 32.83 ms |
| 96449e8 | 361.30 ms | 423.39 ms | 62.09 ms |
| ee747ae | 554.98 ms | 611.50 ms | 56.52 ms |
| d217708 | 409.83 ms | 474.72 ms | 64.89 ms |
| fcec2f2 | 311.35 ms | 384.94 ms | 73.59 ms |
| 85d7417 | 347.21 ms | 394.35 ms | 47.15 ms |
| bdbe1f4 | 380.66 ms | 464.44 ms | 83.78 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 7314dbe | 1.58 MiB | 2.10 MiB | 533.45 KiB |
| dcc6bbf | 1.58 MiB | 2.12 MiB | 553.10 KiB |
| a5ab36f | 1.58 MiB | 2.12 MiB | 555.26 KiB |
| 27d7cf8 | 1.58 MiB | 2.12 MiB | 549.42 KiB |
| 96449e8 | 1.58 MiB | 2.11 MiB | 539.35 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| d217708 | 1.58 MiB | 2.10 MiB | 532.97 KiB |
| fcec2f2 | 1.58 MiB | 2.12 MiB | 551.51 KiB |
| 85d7417 | 1.58 MiB | 2.10 MiB | 533.44 KiB |
| bdbe1f4 | 1.58 MiB | 2.11 MiB | 538.88 KiB |
lcian
approved these changes
Oct 9, 2025
| } | ||
|
|
||
| @ApiStatus.Internal | ||
| public static boolean hasScopes() { |
Member
There was a problem hiding this comment.
Hmm yeah I would prefer this option, however for the purpose of the release I'm fine to go with this for now
sentry-reactor/src/main/java/io/sentry/reactor/SentryReactorThreadLocalAccessor.java
Outdated
Show resolved
Hide resolved
43jay
pushed a commit
that referenced
this pull request
Nov 25, 2025
…es (#4793) * Avoid forking rootScopes for Reactor if current thread has NoOpScopes * release: 8.23.1-alpha.1 * fix changelog; replace hasScopes with bool param on getCurrentScopes * move changelog entry * move changelog again --------- Co-authored-by: getsentry-bot <bot@sentry.io> Co-authored-by: getsentry-bot <bot@getsentry.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Avoid forking
rootScopesfor Reactor if current thread has NoOpScopes.SentryReactorThreadLocalAccessor.getValue()invokesSentry.getCurrentScopes()which will forkrootScopesif there is no instance ofIScopesavailable (nullorNoOpScopes).We now check for existence of
IScopesbefore invokinggetCurrentScopes()in order to avoid the unnecessary overhead.💡 Motivation and Context
Potential fix for #4762
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps