39 lines
1.6 KiB
Markdown
39 lines
1.6 KiB
Markdown
# 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.
|