feat(stats): report the longest path per hour in /stats/paths

This commit is contained in:
MrAlders0n authored and MrAlders0n committed 2026-10-02 13:57:54 -04:00
1 parent 98006a9364
commit 3e0b6c074c
9 files changed
+72 -2

No files matched your search

+5 -1
View File
@@ -24,7 +24,9 @@ WITH readings AS (
SELECT (grouping(hour) = 0)::boolean AS is_hourly,
COALESCE(hour, 'epoch'::timestamptz)::timestamptz AS hour,
category, hash_bytes, COALESCE(entries, 0)::integer AS entries,
sum(receptions)::bigint AS receptions
sum(receptions)::bigint AS receptions,
-- Non-routed categories store entries = 0, so an hour of only empty paths gives 0.
COALESCE(max(entries) FILTER (WHERE receptions > 0), 0)::integer AS max_entries
FROM readings
GROUP BY GROUPING SETS ((category, hash_bytes, entries), (hour, category, hash_bytes))
ORDER BY is_hourly, hour, category, hash_bytes, entries
@@ -43,6 +45,7 @@ type GetPathStatsRow struct {
HashBytes int32 `json:"hash_bytes"`
Entries int32 `json:"entries"`
Receptions int64 `json:"receptions"`
MaxEntries int32 `json:"max_entries"`
}
// All HTTP aggregates read the hourly rollup, never observations.
@@ -62,6 +65,7 @@ func (q *Queries) GetPathStats(ctx context.Context, arg GetPathStatsParams) ([]G
&i.HashBytes,
&i.Entries,
&i.Receptions,
&i.MaxEntries,
); err != nil {
return nil, err
}