-
-
Notifications
You must be signed in to change notification settings - Fork 277
[Span First #3]: Add active span parenting behaviour and more api scaffolding #3377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/span-first
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/span-first #3377 +/- ##
==================================================
Coverage ? 87.94%
==================================================
Files ? 295
Lines ? 10069
Branches ? 0
==================================================
Hits ? 8855
Misses ? 1214
Partials ? 0 ☔ View full report in Codecov by Sentry. |
|
cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Scope clear() does not reset active spans list
The Scope.clear() method, intended to reset the scope, doesn't clear the _activeSpans list. This leaves stale spans, leading to incorrect parenting for new spans and inconsistency with other cleared collection fields.
packages/dart/lib/src/scope.dart#L297-L316
sentry-dart/packages/dart/lib/src/scope.dart
Lines 297 to 316 in 144405e
| /// Resets the Scope to its default state | |
| Future<void> clear() async { | |
| clearAttachments(); | |
| level = null; | |
| span = null; | |
| _transaction = null; | |
| _fingerprint = []; | |
| _tags.clear(); | |
| _extra.clear(); | |
| _eventProcessors.clear(); | |
| _replayId = null; | |
| propagationContext = PropagationContext(); | |
| _attributes.clear(); | |
| _clearBreadcrumbsSync(); | |
| _setUserSync(null); | |
| await clearBreadcrumbs(); | |
| await setUser(null); | |
| } |
packages/dart/lib/src/scope.dart#L45-L78
sentry-dart/packages/dart/lib/src/scope.dart
Lines 45 to 78 in 144405e
| final List<Span> _activeSpans = []; | |
| @visibleForTesting | |
| List<Span> get activeSpans => List.unmodifiable(_activeSpans); | |
| /// Returns the currently active span, or `null` if no span is active. | |
| /// | |
| /// The active span is the most recently set span via [setActiveSpan]. | |
| /// When starting a new span with `active: true` (the default), the new span | |
| /// becomes a child of this active span. | |
| @internal | |
| Span? getActiveSpan() { | |
| return _activeSpans.lastOrNull; | |
| } | |
| /// Sets the given [span] as the currently active span. | |
| /// | |
| /// Active spans are used to automatically parent new spans. | |
| /// When a new span is started with `active: true` (the default), it becomes | |
| /// a child of the currently active span. | |
| @internal | |
| void setActiveSpan(Span span) { | |
| _activeSpans.add(span); | |
| } | |
| /// Removes the given [span] from the active spans list. | |
| /// | |
| /// This should be called when a span ends to remove it from the active | |
| /// span hierarchy. | |
| @internal | |
| void removeActiveSpan(Span span) { | |
| _activeSpans.remove(span); | |
| } |
📜 Description
Span first initiative
💡 Motivation and Context
Part of #3331
💚 How did you test it?
Unit tests
📝 Checklist
sendDefaultPiiis enabled🔮 Next steps
#skip-changelog