feat: SentryOptions.EnableMetrics is obsolete and ignored - #5509
Merged
Conversation
Per the latest cross-SDK guidance, the manual metrics and logs APIs must not be gated behind `enableMetrics`/`enableLogs`. In .NET, `SentrySdk.Metrics` is the only consumer of `EnableMetrics` — it gated `SentryMetricEmitter.Create`, and nothing else reads the option — so ungating the manual API and ignoring the option are the same change. The option itself is not removed: it stays on `SentryOptions`, still binds from configuration, and is now marked obsolete with removal scheduled for 7.0.0. There was never a double opt-in to fix here, since it already defaulted to `true` and metrics are not a separate integration. To drop metrics, use `SetBeforeSendMetric` and return null. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5509 +/- ##
==========================================
- Coverage 74.74% 74.73% -0.02%
==========================================
Files 513 513
Lines 18829 18828 -1
Branches 3682 3681 -1
==========================================
- Hits 14074 14071 -3
- Misses 3875 3877 +2
Partials 880 880 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jamescrosswell
marked this pull request as ready for review
August 27, 2026 03:04
dingsdax
self-requested a review
August 27, 2026 05:17
dingsdax
approved these changes
Aug 27, 2026
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.
Guidance
enableMetricsin a minor; remove in the next major[Obsolete], removal scheduled for 7.0.0SentrySdk.Metricsis gatedtrueby default, not a separate integrationtrueSo the only mandated change is ungating the manual API — and in .NET that happens to be the whole option.
EnableMetricshad exactly one functional consumer,SentryMetricEmitter.Create, which backsSentrySdk.Metrics. Nothing else reads it: there is no automatic metric collection to keep gating. Ungating the manual API and ignoring the option are therefore the same edit.Not a removal
The option stays on
SentryOptions, still binds from configuration (an existing"EnableMetrics"key resolves and is ignored rather than throwing), and keeps its place inBindableSentryOptions. The getter returnstrue, the setter is a no-op, and the obsolete message names 7.0.0 as the removal version. To drop metrics, useSetBeforeSendMetricand returnnull.Notes for review
TraceConnectedMetricsAnalyzerTestshad anInitmethod in its analyzer source snippet whose only purpose was settingEnableMetrics = false. With the option obsolete that snippet emits CS0618, which the Roslyn test harness reports as an unexpected diagnostic, so the method was dropped — it contributed nothing to what the analyzer test covers.🤖 Generated with Claude Code