feat: add quantiles() method to LatencyTracker for OpenMetrics
Returns {count, sum, 0.5, 0.95, 0.99} in seconds for Prometheus
summary exposition. Companion to the existing stats() (milliseconds).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,23 @@ class TestLatencyTracker:
|
||||
assert s["min"] == 500.0
|
||||
assert s["max"] == 500.0
|
||||
|
||||
def test_quantiles_empty(self):
|
||||
lt = LatencyTracker()
|
||||
assert lt.quantiles() is None
|
||||
|
||||
def test_quantiles_seconds(self):
|
||||
lt = LatencyTracker()
|
||||
for i in range(1, 101):
|
||||
lt.record(i / 1000)
|
||||
q = lt.quantiles()
|
||||
assert q is not None
|
||||
assert q["count"] == 100
|
||||
assert 0.050 <= q["0.5"] <= 0.052
|
||||
assert 0.095 <= q["0.95"] <= 0.097
|
||||
assert 0.099 <= q["0.99"] <= 0.101
|
||||
assert "sum" in q
|
||||
assert q["sum"] > 0
|
||||
|
||||
|
||||
# -- RateTracker -------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user