Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
src/live-metrics.ts: rolling counters and p50/p95, rendered as Prometheus text - a pure module with unit tests #114
I added Software/so101/src/live-metrics.ts and src/live-metrics.test.ts. They touch no route or page. The five new tests pass.
stopped parked by the crew deploy e71fd81
2 earlier comments
I added Software/so101/src/live-metrics.ts and src/live-metrics.test.ts. They touch no route or page. The five new tests pass. bun x tsc --noEmit printed only a read-only-tempdir warning and no type errors, but I couldn't confirm a clean exit.
LiveMetricsclass: it hasobserve,count,gauge,snapshot,prometheusandsummaryLine, and takes an injectable clock for tests.- Timings:
observekeeps the last 256 samples in a fixedFloat64Arrayring. The snapshot gives p50, p95, count and sum using nearest-rank percentiles. - Counters:
countuses 60 one-second buckets in fixed arrays. The rate is the sum over the last 60 seconds divided by 60, and the all-time total is kept as well. - Allocation: updates only write into those arrays. Sorting for percentiles happens in
snapshot(), which does allocate. - Names: metric names must match
[a-z_][a-z0-9_]*and be at most 64 characters, otherwise the call throws. Non-finite values are also refused. - Labels: the API has no caller-supplied labels, so the only label is the fixed
quantileone on timings, which goes throughescapeLabel. If you want caller-supplied labels, that needs an API addition. - Prometheus output: timings render as
<name>_mssummaries, counters as<name>_totalplus<name>_rate, and gauges as<name>. - Tests: they cover 10/200 ms p50/p95, the timing window dropping old samples, counters rolling off after 60 s, every non-comment
prometheus()line parsing, and bad names being refused.
🤖 Generated with Claude Code
I haven't pushed anything for #114. The failure doesn't come from my change, so I couldn't find a code fix.
- The failed run: it is the preview deploy, not the check. Its summary reads
ready: /status answered 503 for 30s — … (arm 100.89.95.68:8101: reconnecting). - Why it's unrelated: the preview waits for
/statusto answer, and/statusreturns 503 while the app can't reach the physical arm at100.89.95.68:8101. My two files are a new module and its test, and nothing imports them. - The check itself: it was still
queuedand hadn't run when I looked, so I have no log showing a test or type failure. - What I ran before pushing:
bun test src/live-metrics.test.tspasses (5 tests) andbun x tsc --noEmitshowed no type errors. I changed nothing since.
Changing the code to chase a 503 caused by the arm link would be guessing. If the check does fail once it runs, send me its log and I'll fix that. Otherwise the deploy probably needs a re-run once the arm is reachable.
Parked by the crew: the preview's deploy failed in the place it ran, not in the change, and it could not be run again
I added
Software/so101/src/live-metrics.tsandsrc/live-metrics.test.ts. They touch no route or page. The five new tests pass.bun x tsc --noEmitprinted only a read-only-tempdir warning and no type errors, but I couldn't confirm a clean exit.LiveMetricsclass: it hasobserve,count,gauge,snapshot,prometheusandsummaryLine, and takes an injectable clock for tests.observekeeps the last 256 samples in a fixedFloat64Arrayring. The snapshot gives p50, p95, count and sum using nearest-rank percentiles.countuses 60 one-second buckets in fixed arrays. The rate is the sum over the last 60 seconds divided by 60, and the all-time total is kept as well.snapshot(), which does allocate.[a-z_][a-z0-9_]*and be at most 64 characters, otherwise the call throws. Non-finite values are also refused.quantileone on timings, which goes throughescapeLabel. If you want caller-supplied labels, that needs an API addition.<name>_mssummaries, counters as<name>_totalplus<name>_rate, and gauges as<name>.prometheus()line parsing, and bad names being refused.🤖 Generated with Claude Code
Closes #109