Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: sync environment to the native layers - #5365

#5365
Merged
jamescrosswell merged 15 commits into
maingetsentry/sentry-dotnet:mainfrom
feat/sync-scope-environmentgetsentry/sentry-dotnet:feat/sync-scope-environmentCopy head branch name to clipboard
Jul 15, 2026
Merged

feat: sync environment to the native layers#5365
jamescrosswell merged 15 commits into
maingetsentry/sentry-dotnet:mainfrom
feat/sync-scope-environmentgetsentry/sentry-dotnet:feat/sync-scope-environmentCopy head branch name to clipboard

Conversation

@bitsandfoxes

@bitsandfoxes bitsandfoxes commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Closes #5385

The scope exposes Environment to be overwritten after initialization by the user. This needs to be propagated to the respective native layers. API available on

  • sentry-native
  • sentry-cocoa
  • sentry-java needs to be followed up on.

We need to make sure that whatever it is that the SDK will end up setting on an event is also available on the native layer. The Enricher lazily guarantees that the context is getting populated, so clearing the Scope needs to restore the native scope to the fallback.

Initially, I thought we needed to have the Scope fetch and set the Environment from the options on the backing field in the constructor. The idea was that we'd avoid any duplicate scope sync. But this would only be an issue on non-global-mobe platforms, and those don't have scope sync in the first place.
So we can "get away" with simply having Environment be a smarter property.

Changelog Entry

The Environment set on the Scope now gets synchronized to the native layers (sentry-cocoa and sentry-native)

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jul 9, 2026
Comment thread src/Sentry/Scope.cs
Comment thread src/Sentry/Platforms/Native/CFunctions.cs
@bitsandfoxes
bitsandfoxes marked this pull request as draft July 9, 2026 17:41
Comment thread src/Sentry/IScopeObserver.cs
Comment thread src/Sentry/IScopeObserver.cs
Comment thread src/Sentry/Scope.cs Outdated
@github-actions github-actions Bot added the public API Additions/modifications to, or removals from, the public API surface area. label Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.23%. Comparing base (b302e47) to head (b7dd7fb).

Files with missing lines Patch % Lines
src/Sentry/Internal/ScopeObserver.cs 0.00% 4 Missing ⚠️
src/Sentry/Platforms/Native/NativeScopeObserver.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5365      +/-   ##
==========================================
- Coverage   74.25%   74.23%   -0.02%     
==========================================
  Files         509      509              
  Lines       18420    18435      +15     
  Branches     3606     3610       +4     
==========================================
+ Hits        13677    13685       +8     
- Misses       3869     3875       +6     
- Partials      874      875       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bitsandfoxes
bitsandfoxes marked this pull request as ready for review July 13, 2026 08:01
Comment thread src/Sentry/Scope.cs Outdated
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: medium PR risk score: medium labels Jul 13, 2026
@bitsandfoxes
bitsandfoxes requested a review from Flash0ver July 13, 2026 13:50
Comment thread src/Sentry/Scope.cs

@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 2 potential issues.

Fix All in Cursor

❌ 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 490cc8f. Configure here.

Comment thread src/Sentry/Scope.cs
Comment thread src/Sentry/Scope.cs
evgenygunko pushed a commit to evgenygunko/CopyWordsDA that referenced this pull request Jul 27, 2026
> ℹ️ **Note**
> 
> This PR body was truncated due to platform limits.

This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [Sentry.Maui](https://sentry.io/) ([source](https://github.com/getsentry/sentry-dotnet)) | `6.7.0` → `6.8.0` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/Sentry.Maui/6.8.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Sentry.Maui/6.7.0/6.8.0?slim=true) |

---

### Release Notes

<details>
<summary>getsentry/sentry-dotnet (Sentry.Maui)</summary>

### [`v6.8.0`](https://github.com/getsentry/sentry-dotnet/blob/HEAD/CHANGELOG.md#680)

[Compare Source](getsentry/sentry-dotnet@6.7.0...6.8.0)

##### Features ✨

##### Logs

- feat(logs): add `log4net` integration by [@&#8203;Flash0ver](https://github.com/Flash0ver) in [#&#8203;5172](getsentry/sentry-dotnet#5172)
- feat(logs): add `NLog` integration by [@&#8203;Flash0ver](https://github.com/Flash0ver) in [#&#8203;5176](getsentry/sentry-dotnet#5176)

##### Other

- feat(serilog): support restrictedToMinimumLevel when configuring Serilog in code by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;5181](getsentry/sentry-dotnet#5181)
- Attachments can now be sent with transactions by setting `AddToTransactions` on `SentryAttachment` [#&#8203;5182](getsentry/sentry-dotnet#5182) by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;5182](getsentry/sentry-dotnet#5182)
- Added `SentrySdk.RecordTransaction` to record already-completed transactions and spans (e.g. replayed through a proxy) [#&#8203;5333](getsentry/sentry-dotnet#5333) by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;5333](getsentry/sentry-dotnet#5333)
- The `Environment` set on the `Scope` now gets synchronized to the native layers (`sentry-cocoa` and `sentry-native`) by [@&#8203;bitsandfoxes](https://github.com/bitsandfoxes) in [#&#8203;5365](getsentry/sentry-dotnet#5365)

##### Fixes 🐛

- fix: `SentrySpanProcessor` no longer leaks spans whose Activity never ends (e.g. aborted requests); the Activity is now held via a `WeakReference` so orphaned spans are pruned once it is garbage-collected. by [@&#8203;Ermabo](https://github.com/Ermabo) in [#&#8203;5393](getsentry/sentry-dotnet#5393)
- The SDK was incorrectly ignoring server rate limits for errors, check-ins, and logs by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;5412](getsentry/sentry-dotnet#5412)
- fix: BackpressureMonitor.Dispose() no longer deadlocks on single-threaded targets by [@&#8203;jamescrosswell](https://git...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

public API Additions/modifications to, or removals from, the public API surface area. risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync Environment via IScopeObserver in Hybrid SDK scenarios

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.