Skip to content

feat(metrics): add distribution metric support#545

Open
phacops wants to merge 1 commit into
mainfrom
claude/distribution-metric-support-a67ys4
Open

feat(metrics): add distribution metric support#545
phacops wants to merge 1 commit into
mainfrom
claude/distribution-metric-support-a67ys4

Conversation

@phacops

@phacops phacops commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds support for distribution metrics to Arroyo's metrics backend interface, alongside the existing increment, gauge, and timing methods.

Distribution metrics let backends record the full distribution of a set of values (e.g. percentiles), which is useful for measuring things like batch sizes or latencies where aggregate statistics matter.

Changes

  • arroyo/utils/metrics.py: Add the abstract distribution method to the Metrics protocol and a no-op implementation in DummyMetricsBackend.
  • tests/metrics.py: Add a Distribution call type and implement distribution in the testing backend so recorded distribution calls can be asserted in tests.
  • tests/utils/test_metrics.py: Add a test covering the testing backend's distribution method.
  • docs/source/metrics.rst: Document distribution in the example backend implementation.
  • CHANGELOG.md: Add an Unreleased entry.

Notes

This is purely additive to the metrics interface. Backends implementing the Metrics protocol will now need to provide a distribution method.

Testing

  • pytest tests/utils/test_metrics.py passes.
  • Verified DummyMetricsBackend and the testing backend still satisfy the runtime_checkable Metrics protocol.

🤖 Generated with Claude Code

https://claude.ai/code/session_019ASHzHqVirSvv3vBRYaQPS


Generated by Claude Code

Add a `distribution` method to the metrics backend interface, alongside
the existing `increment`, `gauge`, and `timing` methods. This allows
backends to record distribution metrics.

- Add abstract `distribution` to the `Metrics` protocol
- Implement no-op `distribution` in `DummyMetricsBackend`
- Add `Distribution` call type and implementation in the testing backend
- Document `distribution` in the metrics docs
- Add a test for the testing backend's `distribution`

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ASHzHqVirSvv3vBRYaQPS
@phacops phacops requested review from a team as code owners June 28, 2026 14:59
@untitaker

untitaker commented Jun 28, 2026

Copy link
Copy Markdown
Member

Distribution metrics let backends record the full distribution of a set of values (e.g. percentiles), which is useful for measuring things like batch sizes or latencies where aggregate statistics matter.

okay but we already use timing everywhere, and arroyo isn't prescriptive about how you aggregate those values already. so you could impl timing as a histogram, sampled quantiles, or both, or anything else. is the plan to introduce new metrics that use distribution? right now this dead code.

(don't have access to the claude session so I can't figure out what the bigger picture here is)

phacops commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

With us moving away from veneur and using ddog-statsd, we can now use real distribution metrics instead of the histogram + split into different percentile metrics at veneur.

This PR is adding support for these metrics in Arroyo so we can use them in Snuba consumers https://github.com/getsentry/snuba/blob/10cd401703ce9bd5c838ad38a99a834d4c963957/rust_snuba/src/metrics/statsd.rs#L124-L162

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.

3 participants