Shared aggregation helpers for the actor engine.
Extracted from TimelessMetrics.Query — bucket_to_seconds, compute_aggregate,
and bucket_points are needed by both the sharded query engine and the actor
engine's in-process aggregation.
Summary
Functions
Group points into time buckets and compute an aggregate per bucket.
Per-bucket counter rate with carry-in.
Convert a bucket spec to seconds.
Compute an aggregate value from a list of values.
Functions
Group points into time buckets and compute an aggregate per bucket.
Returns [{bucket_timestamp, aggregate_value}, ...] sorted by timestamp.
Per-bucket counter rate with carry-in.
Takes timestamp-sorted points and an alignment function ts -> bucket_ts.
Each bucket's rate is computed from pairwise deltas over the bucket's points
plus the last point of the previous bucket (so one-sample-per-bucket data —
the common scrape case — still yields rates). Negative deltas (counter
resets) are skipped. Buckets with no computable delta are omitted, matching
Prometheus/VM (no rate at the first sample).
Returns [{bucket_timestamp, rate_per_second}, ...] sorted by timestamp.
Convert a bucket spec to seconds.
Compute an aggregate value from a list of values.