Skip to content

fix(tracing): Restore scope transaction after streamed segment ends - #8049

Open
kcons wants to merge 1 commit into
masterfrom
kcons/fixtrans
Open

kcons wants to merge 1 commit into
masterfrom
kcons/fixtrans

Conversation

@kcons

@kcons kcons commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Streamed root segments wrote their name and source to the scope but never restored them on end, so later error events picked up a stale transaction. Save and restore both, and drop an inherited source when a no-op segment starts without one.

#7774 was closed on the basis that span streaming avoids this, but the same leak exists in streamed_span. This fix snapshots and restores state per root segment, so ending a child span doesn't clear the transaction (the concern raised on #7773).

Refs #7774

@kcons
kcons requested a review from a team as a code owner October 16, 2026 17:21
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 133768 passed | ⏭️ 7276 skipped | Total: 141044 | Pass Rate: 94.84% | Execution Time: 478m 33s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +102
Passed Tests 📈 +102
Failed Tests —
Skipped Tests —

All tests are passing successfully.

✅ Patch coverage is 94.44% (17 of 18 changed executable lines covered; target 80%).
Project statement coverage is 90.24% (down 0.02 percentage points from base (0f7acd5) to head (069518d)).

Changed files with executable lines (2)
File Patch coverage Changed executable lines
sentry_sdk/traces.py 100.00% 16/16 covered; partial branches: 708, 737
sentry_sdk/scope.py 50.00% 1/2 covered; missed: 937
Coverage diff
@@            Coverage Diff             @@
##        master     #8049       +/-##
==========================================
- Coverage    90.26%    90.24%    -0.02%
==========================================
  Files          202       202         —
  Tracked lines     26660     26678       +18
  Branches      9926      9934        +8
==========================================
+ Hits         24062     24073       +11
- Misses        2598      2605        +7
- Partials      1510      1511        +1

Generated by Coverage Action

This branch has not been deployed

No deployments
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.

1 participant