Skip to content

feat(scopes): Add sentry_scope_clear()#1881

Merged
limbonaut merged 3 commits into
masterfrom
limbonaut/feat/scope-clear
Jul 17, 2026
Merged

feat(scopes): Add sentry_scope_clear()#1881
limbonaut merged 3 commits into
masterfrom
limbonaut/feat/scope-clear

Conversation

@limbonaut

@limbonaut limbonaut commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Adds sentry_scope_clear, which resets the given scope data (user, tags, breadcrumbs, attributes, and so on) to a fresh state while keeping its trace, so a reusable scope can be cleared and used again.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 91efc56

Comment thread src/sentry_scope.c
Comment on lines +221 to +222
// Keep the propagation and dynamic sampling contexts across clears so
// telemetry captured afterwards continues on the same trace.

@limbonaut limbonaut Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I aligned this implementation with Cocoa and Android. I didn't find much details on scope.clear() in the specs, so borrowed this part from other SDKs.

spec: Reset scope to defaults, keeping event processors.

It makes sense that the scope.clear() doesn't drop trace defaults.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current shape, this is close to no-op, because user-created scopes carry no default trace, and it's picked up from the global scope instead. But this may change if we introduce propagation context mutators.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.60%. Comparing base (947def6) to head (91efc56).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1881      +/-   ##
==========================================
+ Coverage   75.56%   75.60%   +0.04%     
==========================================
  Files          90       90              
  Lines       21169    21188      +19     
  Branches     3763     3764       +1     
==========================================
+ Hits        15996    16020      +24     
+ Misses       4346     4333      -13     
- Partials      827      835       +8     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@limbonaut
limbonaut merged commit 59cb293 into master Jul 17, 2026
67 checks passed
@limbonaut
limbonaut deleted the limbonaut/feat/scope-clear branch July 17, 2026 11:57
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.

2 participants