Skip to content

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Oct 9, 2025

📜 Description

Avoid forking rootScopes for Reactor if current thread has NoOpScopes.

SentryReactorThreadLocalAccessor.getValue() invokes Sentry.getCurrentScopes() which will fork rootScopes if there is no instance of IScopes available (null or NoOpScopes).

We now check for existence of IScopes before invoking getCurrentScopes() in order to avoid the unnecessary overhead.

💡 Motivation and Context

Potential fix for #4762

💚 How did you test it?

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

cursor[bot]

This comment was marked as outdated.

}

@ApiStatus.Internal
public static boolean hasScopes() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah I would prefer this option, however for the purpose of the release I'm fine to go with this for now

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 313.63 ms 353.94 ms 40.31 ms
Size 1.58 MiB 2.12 MiB 555.28 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
806307f 357.85 ms 424.64 ms 66.79 ms
ee747ae 554.98 ms 611.50 ms 56.52 ms
17a0955 372.53 ms 446.70 ms 74.17 ms
2124a46 319.19 ms 415.04 ms 95.85 ms
9fbb112 404.51 ms 475.65 ms 71.14 ms
b6702b0 395.86 ms 409.98 ms 14.12 ms
ee747ae 357.79 ms 421.84 ms 64.05 ms
27d7cf8 314.17 ms 347.00 ms 32.83 ms
9fbb112 361.43 ms 427.57 ms 66.14 ms
96449e8 361.30 ms 423.39 ms 62.09 ms

App size

Revision Plain With Sentry Diff
806307f 1.58 MiB 2.10 MiB 533.42 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
17a0955 1.58 MiB 2.10 MiB 533.20 KiB
2124a46 1.58 MiB 2.12 MiB 551.51 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
b6702b0 1.58 MiB 2.12 MiB 551.79 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
27d7cf8 1.58 MiB 2.12 MiB 549.42 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
96449e8 1.58 MiB 2.11 MiB 539.35 KiB

}

@ApiStatus.Internal
public static boolean hasScopes() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah I would prefer this option, however for the purpose of the release I'm fine to go with this for now

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

Successfully merging this pull request may close these issues.

4 participants