fix(compose): allow overriding the IScopes used by SentryTraced via LocalSentryScopes#5838
Open
Tabishahmad wants to merge 1 commit into
Open
fix(compose): allow overriding the IScopes used by SentryTraced via LocalSentryScopes#5838Tabishahmad wants to merge 1 commit into
Tabishahmad wants to merge 1 commit into
Conversation
…ocalSentryScopes SDKs that report their own telemetry through a separate IScopes/Hub instance (distinct from the host app's Sentry setup) previously had no way to make SentryTraced trace against that instance, since it always read from the global Sentry.getCurrentScopes(). LocalSentryScopes can now be overridden via CompositionLocalProvider to scope tracing to a specific IScopes, while sibling SentryTraced calls under the same scopes still share one root composition/render span. Fixes getsentry#2668
Tabishahmad
requested review from
0xadam-brown,
adinauer,
markushi,
romtsn and
runningcode
as code owners
July 25, 2026 07:04
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.
SDKs that report their own telemetry through a separate IScopes/Hub instance (distinct from the host app's Sentry setup) previously had no way to make SentryTraced trace against that instance, since it always read from the global Sentry.getCurrentScopes(). LocalSentryScopes can now be overridden via CompositionLocalProvider to scope tracing to a specific IScopes, while sibling SentryTraced calls under the same scopes still share one root composition/render span.
📜 Description
Adds a public
LocalSentryScopesCompositionLocal tosentry-compose, defaulting toSentry.getCurrentScopes()and overridable viaCompositionLocalProvider(LocalSentryScopes provides myScopes) { ... }.SentryTracednow resolves the currentIScopesfromLocalSentryScopesinstead of always reading the global default. The root "Initial Composition" / "Initial Render" spans are cached perIScopesin a shared holder so that siblingSentryTracedcalls under the same scopes still share one root span (matching current behavior), while calls under different scopes each get their own independent root span.💡 Motivation and Context
Enables SDKs/libraries that report their own telemetry through a separate
IScopes/Hubinstance to useSentryTracedagainst that instance, independently of the host app's own Sentry setup. Direction confirmed with @markushi and @romtsn on the issue.💚 How did you test it?
Added
SentryTracedTestcovering:IScopesprovided viaLocalSentryScopesSentryTracedcalls under the same scopes share one root spanSentryTracedcalls under different scopes don't interfere with each otherExisting
ComposeIntegrationTestsstill pass.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Update public API docs for
sentry-composeonce this lands, to documentLocalSentryScopes.