Add tickets to improve metric abstractions

This commit is contained in:
Hugh Kaznowski
2026-09-05 22:20:03 +01:00
parent 85fb145be7
commit 930a2f2536
7 changed files with 281 additions and 0 deletions
@@ -0,0 +1,38 @@
# 042 — Verify/fix exact-timestamp merging for non-rate sum()/avg()
## Summary
Non-rate `sum()`/`avg()` queries merge per-label series via
`merge_series_exact` (`src/engine.rs`), which only combines values whose
timestamps match *exactly*. In practice, raw occurrence timestamps across
different label groups essentially never land on the same millisecond, so
`sum(requests) by (path)` over raw occurrence counts likely produces sparse,
near-empty merged series rather than a meaningful "total requests over
time," even though that's the obvious expectation for such a query. The
existing code comment justifying exact-match merging ("nothing to carry
forward") only holds if the query isn't meant to sum sparse counts over
time — which is exactly the common case for occurrence-count dashboards.
## Scope
- Build a seeded fixture with multiple label groups whose events arrive at
different (non-coincident) timestamps and confirm whether
`sum(...) by (...)` currently produces the expected combined total or the
suspected sparse/near-empty result.
- If confirmed broken: bucket points into fixed time windows (the same way
`rate()` already windows) before summing/averaging across label groups,
instead of requiring exact timestamp coincidence.
- Add a regression test covering multi-label-group `sum()`/`avg()` over
time.
## Acceptance criteria
- `sum(metric) by (label)` over multiple label groups with staggered event
timestamps produces a sensible combined time series (not sparse/empty),
verified by a new test fixture.
- `avg()` behaves analogously.
- Existing single-label-group queries are unaffected.
## Depends on
None.