Skip to content

feat: SentryOptions.EnableMetrics is obsolete and ignored - #5509

Merged
jamescrosswell merged 1 commit into
mainfrom
feat/obsolete-enable-metrics
Aug 27, 2026
Merged

feat: SentryOptions.EnableMetrics is obsolete and ignored#5509
jamescrosswell merged 1 commit into
mainfrom
feat/obsolete-enable-metrics

Conversation

@jamescrosswell

@jamescrosswell jamescrosswell commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Guidance

Guidance .NET metrics today Action
Don't remove enableMetrics in a minor; remove in the next major Kept, marked [Obsolete], removal scheduled for 7.0.0
Don't gate the manual APIs behind the option SentrySdk.Metrics is gated Fixed here
No real double opt-in Already true by default, not a separate integration Nothing to do
Don't change the default if it forces other opt-in config Default was already true Nothing to do
Auto-added integrations must not send metrics No such integrations N/A

So the only mandated change is ungating the manual API — and in .NET that happens to be the whole option. EnableMetrics had exactly one functional consumer, SentryMetricEmitter.Create, which backs SentrySdk.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 in BindableSentryOptions. The getter returns true, the setter is a no-op, and the obsolete message names 7.0.0 as the removal version. To drop metrics, use SetBeforeSendMetric and return null.

Notes for review

TraceConnectedMetricsAnalyzerTests had an Init method in its analyzer source snippet whose only purpose was setting EnableMetrics = 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

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

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.73%. Comparing base (4e0e0de) to head (6380616).
⚠️ Report is 1 commits behind head on main.

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.
📢 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.

@jamescrosswell jamescrosswell modified the milestone: 7.0.0 Aug 26, 2026
@jamescrosswell
jamescrosswell marked this pull request as ready for review August 27, 2026 03:04
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Aug 27, 2026
@dingsdax
dingsdax self-requested a review August 27, 2026 05:17
@jamescrosswell
jamescrosswell merged commit c6a123c into main Aug 27, 2026
60 of 61 checks passed
@jamescrosswell
jamescrosswell deleted the feat/obsolete-enable-metrics branch August 27, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants