fix(compose): Prevent dangling spans in SentryTraced + tag composition outcome - #6049
Merged
Conversation
📲 Install BuildsAndroid
|
0xadam-brown
force-pushed
the
fix/sentry-traced-dangling-spans
branch
from
September 3, 2026 03:49
d698dce to
3e66b34
Compare
0xadam-brown
commented
Sep 3, 2026
0xadam-brown
marked this pull request as ready for review
September 3, 2026 04:02
0xadam-brown
requested review from
adinauer,
markushi,
romtsn and
runningcode
as code owners
September 3, 2026 04:02
0xadam-brown
marked this pull request as draft
September 3, 2026 05:15
Commit repairs a few defects in the implementation of SentryTraced while aiming to maintain parity with the previous approach. In particular it: - Prevents dangling composition spans in cases where the Compose runtime abandons the composition. (We now delay creating the span until a SideEffect executes.) - Prevents dangling render spans in cases where drawContent() throws and the host app recovers. (Similarly, we delay creating the span until drawContent() completes successfully.)
0xadam-brown
force-pushed
the
fix/sentry-traced-dangling-spans
branch
from
September 3, 2026 07:02
3e66b34 to
a85abfe
Compare
0xadam-brown
marked this pull request as ready for review
September 3, 2026 07:27
0xadam-brown
marked this pull request as draft
September 3, 2026 08:16
Member
Author
|
Sorry for the churn. Need to incorporate a few additional changes. Back shortly... |
runningcode
approved these changes
Sep 3, 2026
runningcode
left a comment
Contributor
There was a problem hiding this comment.
LGTM! I'm not an expert in compose so feel free to ignore these comments
Member
Author
|
Ready for review again. No changes from before – the other work was substantial enough that I'll create a separate PR for it. |
0xadam-brown
marked this pull request as ready for review
September 3, 2026 09:03
9 tasks
markushi
approved these changes
Sep 3, 2026
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
PR repairs a few defects in the implementation of
SentryTracedwhile aiming to maintain parity with the previous approach. In particular it:Prevents dangling composition spans in cases where the Compose runtime abandons the composition. (We now delay creating the span until a SideEffect executes.)
Prevents dangling render spans in cases where drawContent() throws and the host app recovers. (Similarly, we delay creating the span until drawContent() completes successfully.)
💡 Motivation and Context
Dangling spans remain attached to their parent transaction and can delay transaction capture if
waitForChildrenis enabled. They're also confusing in the Sentry dashboard because they look like poor performing compositions, when in fact they will have simply been abandoned in the ordinary course by the Compose runtime.Spans before vs after
I had my clanker exercise SentryTraced composables in our sample app to test span durations before this change vs after. Expand below to see the results (tl;dr they're comparable, which is what we want).
Details
ui.compose+ 11ui.renderchild spansui.compose+ 21ui.renderchild spansIntegrationsspans in stock flowcomposition.resulttagui.renderoriginmanualmanualui.compose+ 7ui.renderui.compose+ 7ui.renderNote: We're likely seeing more spans after this PR (21 vs 11) because of a race that's always been present between when the root transaction becomes active vs when we start the composition span. We now start later, which means the transaction has more time to set itself up, and therefore fewer spans are lost. I plan to tackle this problem fully with the introduction of
LocalSentrySpanin a subsequent PR.💚 How did you test it?
Unit tests and manual tests.
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Two more
SentryTracedrelated PRs:LocalSentrySpanCompositionLocal.