fix(otel): only set Scope.Transaction in SentrySpanProcessor when null#5337
fix(otel): only set Scope.Transaction in SentrySpanProcessor when null#5337tsushanth wants to merge 3 commits into
Conversation
|
Thank you very much, @tsushanth, for your contribution to the Sentry .NET SDK! |
Rewrite test to exercise CreateRootSpan directly via ScopeManager, use correct types, and remove noisy inline comments per review feedback.
8a3f87c to
8a20eba
Compare
|
Thanks for the detailed review @Flash0ver! Updated:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8a20eba. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5337 +/- ##
==========================================
+ Coverage 74.16% 74.20% +0.03%
==========================================
Files 508 509 +1
Lines 18353 18389 +36
Branches 3586 3601 +15
==========================================
+ Hits 13612 13645 +33
- Misses 3869 3870 +1
- Partials 872 874 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Sorry about the delay — was pushing to the wrong local branch name. Commits are now on the correct branch: |
|
thanks ... I'll take another look in the morning (CEST) |

Fixes #5314.
Problem
SentrySpanProcessor.OnStartcallsConfigureScopeunconditionally:When two root OTel activities overlap and neither is a child of the other, this silently overwrites whatever transaction was already on the scope with the new one. As the issue notes, the intuitive default is to not overwrite an existing transaction.
Fix
Add a null-check guard inside the
ConfigureScopelambda:Scope.Transactionis only set when it is currentlynull; an already-present transaction is left unchanged.Test
Added
OnStart_WithExistingTransactionOnScope_DoesNotOverwriteExistingTransactiontoSentrySpanProcessorTests: sets a transaction on the scope, starts a new root activity, callsOnStart, and asserts the scope still holds the original transaction.This is intentionally not bundled with #2399 (the
AutoSetScopeTransactionsopt-in), per the issue's notes.