Skip to content

feat(scope): Scoped logs and metrics capture - #1861

Merged
limbonaut merged 17 commits into
masterfrom
limbonaut/feat/scoped-logs-metrics
Jul 17, 2026
Merged

limbonaut merged 17 commits into
masterfrom
limbonaut/feat/scoped-logs-metrics

Conversation

@limbonaut

@limbonaut limbonaut commented Jul 13, 2026 •

Copy link
Copy Markdown
Collaborator

This PR makes scope attributes a public, working part of the API. It promotes the previously-internal sentry_scope_set_attribute/_n and sentry_scope_remove_attribute/_n to public, and adds sentry_scope_capture_log and sentry_scope_capture_metric so a log or metric can be captured against a specific scope and pick up that scope's attributes and trace. Both trace and attributes now flow onto logs and metrics with spec-correct precedence, resolving most-specific-first: per-call attributes, then the passed scope, then the global scope.

Needed for current scopes and performance API in the Godot SDK. See rationale in #1838.

I plan to add sentry_scope_set_span/transaction and also sentry_scope_clear as follow-ups.

@limbonaut
limbonaut marked this pull request as ready for review July 16, 2026 12:18
@limbonaut limbonaut changed the title WIP: Scoped logs and metrics capture feat(scope): Scoped logs and metrics capture Jul 16, 2026
Comment thread src/sentry_scope.h Resolved
@github-actions

github-actions Bot commented Jul 16, 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 f4947b8

@limbonaut

limbonaut commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

To check how it would be used, you can see my WIP implementation over here (see NativeSDK::metrics_add_X and project/test/isolated/ tests):

Comment thread src/sentry_scope.c Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f9cb8a1. Configure here.

Comment thread src/sentry_scope.c Resolved
@codecov

codecov Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.53%. Comparing base (88e7bae) to head (f4947b8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1861      +/-   ##
==========================================
- Coverage   75.56%   75.53%   -0.03%     
==========================================
  Files          90       90              
  Lines       21154    21169      +15     
  Branches     3759     3763       +4     
==========================================
+ Hits        15986    15991       +5     
- Misses       4334     4350      +16     
+ Partials      834      828       -6     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@limbonaut
limbonaut merged commit 947def6 into master Jul 17, 2026
63 checks passed
@limbonaut
limbonaut deleted the limbonaut/feat/scoped-logs-metrics branch July 17, 2026 10:49
limbonaut added a commit to getsentry/sentry-docs that referenced this pull request Aug 10, 2026
…18981)

Documents scope attributes for the Native SDK: setting them on the
global scope or on a scope you create, how per-call, scope, and global
attributes are applied, and the scoped capture functions for logs and
metrics. Also corrects the Scopes page, which claimed logs and metrics
resolve a trace from the call site — a scope you create carries no trace
of its own.

- Refs getsentry/sentry-native#1861
- Refs getsentry/sentry-native#1879

## 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:*

- [ ] Checked Vercel preview for correctness, including links
- [ ] 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)
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
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