Repository navigation
feat(scopes): Add sentry_scope_clear() - #1881
Merged
Merged
Conversation
|
limbonaut
commented
Jul 17, 2026
Comment on lines
+221
to
+222
| // Keep the propagation and dynamic sampling contexts across clears so | ||
| // telemetry captured afterwards continues on the same trace. |
Collaborator
Author
There was a problem hiding this comment.
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.
Collaborator
Author
There was a problem hiding this comment.
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.
jpnurmi
approved these changes
Jul 17, 2026
Codecov Report❌ Patch coverage is 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:
|
1 task
3 of 6 tasks
limbonaut
added a commit
to getsentry/sentry-docs
that referenced
this pull request
Aug 7, 2026
) ## DESCRIBE YOUR PR Rewrites the Native SDK's Scopes page, which described a hub-and-scope-stack model the SDK never implemented, and replaces it with the model the SDK actually has: one global scope the SDK creates at `sentry_init()`, plus scopes you create and hand to a capture function. Covers which constructor to use and who frees the scope, how scope data is merged and which source wins, and why only the global scope reaches crash events. Related includes are updated to match, including the swap from the deprecated `sentry_capture_event_with_scope` to `sentry_scope_capture_event`. - User-owned scopes, `sentry_scope_new` / `sentry_scope_free` / `sentry_scope_clone` getsentry/sentry-native#1855 - `sentry_scope_capture_*` naming and the deprecation it replaces getsentry/sentry-native#1882 - `sentry_scope_clear` getsentry/sentry-native#1881 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [x] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: J-P Nurmi <[email protected]>
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
sentry-native 0.15.4 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`. - [ ] `resource` blocks have been checked for updates. <details> <summary>release notes</summary> <pre>**Features**: - Add reusable, user-owned scopes. `sentry_scope_new` creates a scope that `sentry_capture_event_with_scope` applies without consuming, so you can configure it once and reuse it across many captures instead of building a new local scope each time. `sentry_scope_clone` copies a scope, and `sentry_scope_free` releases it. ([#1855](getsentry/sentry-native#1855)) - Android: Expose setting the environment on the scope through the NDK bindings via `NativeScope.setEnvironment()`, so head SDKs can sync the environment at runtime. ([#1874](getsentry/sentry-native#1874)) - Embed the crash event's breadcrumbs into session replay recordings, so breadcrumbs from the replay window show up on the replay timeline. ([#1875](getsentry/sentry-native#1875)) - Add `sentry_transaction_discard` and `sentry_span_discard` for releasing unfinished transactions and spans without sending them. ([#1858](getsentry/sentry-native#1858)) - Add scope attributes. `sentry_scope_set_attribute` / `_n` set an attribute on a scope and `sentry_scope_remove_attribute` / `_n` remove one, while the new `sentry_scope_capture_log` and `sentry_scope_capture_metric` capture a log or metric against a given scope. Scope attributes and trace are applied to logs and metrics captured against it, resolving most-specific-first: per-call data, then the scope, then the global scope. ([#1861](getsentry/sentry-native#1861)) - Add `sentry_scope_clear` to reset a scope's data. ([#1881](getsentry/sentry-native#1881)) **Deprecations**: - Deprecate `sentry_capture_event_with_scope` in favor of `sentry_scope_capture_event` (scope first), which matches `sentry_scope_capture_log` / `sentry_scope_capture_metric`. ([#1882](getsentry/sentry-native#1882)) **Fixes**: - Apply the propagation context to events that already have contexts set, so that events captured with a local scope or with event-level contexts keep their trace. ([#1843](getsentry/sentry-native#1843)) - Crashpad: reject runtime control IPC from processes other than the one that started the handler. ([#1853](getsentry/sentry-native#1853)) - Native/macOS: resolve symbol names for crash stacktraces from Mach-O symbol tables and dSYM companions. ([#1856](getsentry/sentry-native#1856)) - Route libcurl debug output through the Sentry logger (`SENTRY_TRACE`) instead of writing to `stderr`. ([#1854](getsentry/sentry-native#1854)) - NOTE: `sentry_options_set_debug(options, true)` no longer displays verbose libcurl debug output by default. To restore it, call `sentry_options_set_logger_level(options, SENTRY_LEVEL_TRACE)`. - Crashpad: route client logs through the Sentry logger to make actionable handler startup errors visible. ([#1859](getsentry/sentry-native#1859)) - Windows: fix symlink detection used to prevent database cleanup from following symlinks in run and cache directories. ([#1857](getsentry/sentry-native#1857)) - Linux: avoid unsafe `copy_file_range` at crash time. ([#1868](getsentry/sentry-native#1868)) - Increase the default telemetry batcher capacity from 2x100 to 3x100 items, and add `SENTRY_BATCHER_BUFFER_COUNT` to configure the number of rotating buffers used by log and metric batchers. ([#1867](getsentry/sentry-native#1867)) - Fix a lifetime issue when reading `sample_rand` from the scope propagation context. ([#1869](getsentry/sentry-native#1869)) - Linux: silence harmless compilation warnings in `sentry_modulefinder_linux.c` and `sentry_backend_inproc.c`. ([#1871](getsentry/sentry-native#1871)) - Fix per-call log and metric attributes to override same-named global attributes atomically, preventing fields such as `unit` from leaking from the global attribute when the per-call attribute does not define them. ([#1879](getsentry/sentry-native#1879)) - Prefix vendored mpack symbols to avoid symbol conflicts. ([#1880](https://github.com/getsentry/sentry-native/pull/1880))</pre> <p>View the full release notes at <a href="https://github.com/getsentry/sentry-native/releases/tag/0.15.4">https://github.com/getsentry/sentry-native/releases/tag/0.15.4</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!14800
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.
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.