Expand description
The Metrics endpoints’ buckets kept between requests: a bucket whose rows are all written doesn’t change, so each request reads only the buckets since the last final one (the user, 2026-11-15: metrics mustn’t weigh on schedr; 30 days of 100 processes took seconds a request on SQLite, and the Deployments page asks every 15 seconds in each tab).
A bucket is final once it ended FINAL_AFTER ago: a minute sample is stored within the
sampler’s grace of its minute (a webserver’s late one; ROLL_GRACE), a rollup once, and
buckets are aligned to the epoch, so a later request’s buckets are the same ones. A request
for a key waits for one already reading it, so many tabs cost one read.
Structs§
- Cache
Limits - When the cache’s buckets are final, and how much it keeps (decision 493).
- Entry
- One key’s final buckets.
- Key
- What is asked for: the samples of each process (all, or one) or the totals, over a range.
- Series
Cache - The kept buckets of every key.
Constants§
- FINAL_
AFTER - How long after a bucket’s end its rows are all stored: the sampler’s grace (2 minutes) and a minute’s write, with room for the clocks of the processes writing them to differ (Codex’s review: a webserver stamps its own sample by its clock). A sample stored later than this misses its rollup too (2 minutes), and a webserver that read past it shows it once it starts again.
Functions§
- final_
to - The first bucket not final at
to, in buckets ofbucket_s, finalaftertheir end. - keep_
buckets - Keeps
buckets’ final ones (beforefinal_to) of a range startingfrominentry, unless more thanmost. - merged
keptandread(from wherekeptends) as one list by process and time, those beforefromleft out.- merged_
latest - Each process’s latest sample:
kept’s, replaced by a later oneread, those beforefromleft out. - merged_
totals keptandreadtotals as one list by time, those beforefromleft out; the final ones kept inentry.