Skip to content

chore: Remove leftover statsd Metrics protocol code - #5937

Merged
jamescrosswell merged 1 commit into
mainfrom
chore/remove-legacy-statsd-metrics
Nov 16, 2026
Merged

jamescrosswell merged 1 commit into
mainfrom
chore/remove-legacy-statsd-metrics

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Removes the internal leftovers of the old statsd-based Metrics API. Nothing in production calls any of it. The new trace-connected metrics (SentryMetric, TraceMetric, trace_metric envelope items) don't use any of this code and aren't touched.

What's removed (all internal)

  • src/Sentry/Protocol/Metrics/ (the whole folder): Metric, CounterMetric, GaugeMetric, DistributionMetric, SetMetric, CodeLocations, MetricResourceIdentifier, MetricType, MetricsSummary, SpanMetric
  • src/Sentry/MetricHelper.cs and src/Sentry/MetricsSummaryAggregator.cs
  • Hub.CaptureMetrics and Hub.CaptureCodeLocations
  • Envelope.FromMetrics, Envelope.FromCodeLocations, EnvelopeItem.FromMetric(Metric), EnvelopeItem.FromCodeLocations and the metric_meta item type constant
  • SpanTracer and TransactionTracer: MetricsSummary and HasMetrics. SentrySpan and SentryTransaction: the _metricsSummary field and the _metrics_summary serialization
  • Tests for the deleted code: MetricTests, MetricsSummaryTests, MetricHelperTests and their verified snapshots

When it was added: most of it came in #2949 (Metrics Support - alpha), merged 2024-01-08. The span/transaction metrics summary (MetricsSummary, MetricsSummaryAggregator, SpanMetric) came in #3191 (Metrics improvements), merged 2024-03-06.

When it became irrelevant, and why: #3718 (Removed Metrics (deprecated)) was merged into version-5.0.0 on 2024-10-30 and shipped in 5.0.0 on 2024-12-19. It deleted MetricAggregator.cs, which held the only calls to _metricHub.CaptureMetrics(...), _metricHub.CaptureCodeLocations(...) and transactionTracer/spanTracer.MetricsSummary.Add(...). It also deleted IMetricHub, but it left the Hub methods, the protocol types and the summary aggregators in place. None of them have had a caller since then.

Evidence it's unused (on main @ b9a48d2)

  • Outside modules/, nothing in src/, test/, samples/, benchmarks/ or integration-test/ references CaptureMetrics, CaptureCodeLocations, FromCodeLocations, Envelope.FromMetrics, CounterMetric, GaugeMetric, DistributionMetric, SetMetric or MetricResourceIdentifier, except the deleted files and their own tests.
  • SpanTracer.MetricsSummary and TransactionTracer.MetricsSummary are only read inside if (tracer.HasMetrics), and HasMetrics is Lazy.IsValueCreated. Nothing else touches the property, so the lazy value is never created and _metrics_summary is never written.
  • MetricHelper was only used by the deleted protocol types and by MetricsSummaryAggregator.

Why it's not breaking: every removed type and member is internal, and the API approval snapshots don't change. Serialized output doesn't change either, because _metrics_summary could never be written. No target frameworks or package dependencies change.

Left in place on purpose: EnvelopeItem.TypeValueMetric (statsd) and its DataCategory.MetricBucket mapping. Rate-limit category handling and its tests still use them, so removing them is a separate decision. RandomValuesFactory.NextInt(int, int) loses its last caller (MetricHelper.FlushShift) but is part of a shared abstraction, so it's out of scope here.

#skip-changelog

via automation sched_2fb5d12bd3a78841d7d2559c56e8141d · Run ID sched_2fb5d12bd3a78841d7d2559c56e8141d:1794812400000.

--

View Session [Sentry]

The deprecated statsd Metrics API was removed in #3718 (5.0.0), which
deleted MetricAggregator, the only caller of Hub.CaptureMetrics,
Hub.CaptureCodeLocations and the span/transaction MetricsSummary
aggregators. The protocol types, envelope factories, helpers and their
tests stayed behind with no production callers.
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.66%. Comparing base (b9a48d2) to head (72a8a3e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5937      +/-   ##
==========================================
+ Coverage   77.43%   77.66%   +0.22%     
==========================================
  Files         546      534      -12     
  Lines       20053    19714     -339     
  Branches     3962     3932      -30     
==========================================
- Hits        15529    15311     -218     
+ Misses       3659     3547     -112     
+ Partials      865      856       -9     

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

@ric-oliv
ric-oliv marked this pull request as ready for review November 16, 2026 10:20
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 16, 2026
@ric-oliv

Copy link
Copy Markdown
Member

LGTM, I'll leave it for you to merge @jamescrosswell :)

@jamescrosswell
jamescrosswell merged commit 217898c into main Nov 16, 2026
62 of 63 checks passed
@jamescrosswell
jamescrosswell deleted the chore/remove-legacy-statsd-metrics branch November 16, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants