feat(metrics): add distribution metric support#545
Conversation
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 <[email protected]> Claude-Session: https://claude.ai/code/session_019ASHzHqVirSvv3vBRYaQPS
okay but we already use timing everywhere, and arroyo isn't prescriptive about how you aggregate those values already. so you could impl (don't have access to the claude session so I can't figure out what the bigger picture here is) |
|
With us moving away from |
Summary
Adds support for distribution metrics to Arroyo's metrics backend interface, alongside the existing
increment,gauge, andtimingmethods.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 abstractdistributionmethod to theMetricsprotocol and a no-op implementation inDummyMetricsBackend.tests/metrics.py: Add aDistributioncall type and implementdistributionin the testing backend so recorded distribution calls can be asserted in tests.tests/utils/test_metrics.py: Add a test covering the testing backend'sdistributionmethod.docs/source/metrics.rst: Documentdistributionin the example backend implementation.CHANGELOG.md: Add an Unreleased entry.Notes
This is purely additive to the metrics interface. Backends implementing the
Metricsprotocol will now need to provide adistributionmethod.Testing
pytest tests/utils/test_metrics.pypasses.DummyMetricsBackendand the testing backend still satisfy theruntime_checkableMetricsprotocol.🤖 Generated with Claude Code
https://claude.ai/code/session_019ASHzHqVirSvv3vBRYaQPS
Generated by Claude Code