Repository navigation
Closed
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard workscope/telemetryOpenTelemetry tracing spans, Prometheus metrics, and Jaegersource/agentFiled by an agenttype/bugType bug: the code does not do what it mustvalue/highValue High: the delivery of the item matters much
Description
Problem
A cluster Job pod exports its metrics only once, when its process exits. devops-cli keeps its counters in an in-memory DELTA reader (InMemoryMetricReader, src/devops_cli/telemetry/tracer.py:1050) and exports them only when flush() runs. The Service calls tracer.flush() after each round (src/devops_cli/server/service.py:677, :738, #1629), but a Job runs one long command, and its only flush is the atexit shutdown (tracer.py:1693).
Evidence, 2026-11-16, the implement runner Jobs and their samples of devops_cli_ai_tokens_total{job="roadmap-implement"}:
| Job | Ran | Samples |
|---|---|---|
| #3529 | 19:41Z to 20:30Z | one, at 20:30Z |
| #3550 | 20:44Z to 21:26Z | one, at 21:26Z |
| #3569 | 21:43Z to 23:42Z | one, at 23:42Z |
The stage Jobs (job="roadmap-stage") act the same way: about 6 samples for each series in 6 h.
Effects:
- A Job shows no tokens, requests or spend while it runs, also for a run of 2 h.
- A Job that the kernel or the deadline kills never exports, so its usage is lost. In the 6 h to 01:35Z,
litellm_spend_metric_totalgives $1.26 for DeepSeek, anddevops_cli_ai_spend_usd_totalgives $0.68. rate(...[5m])never sees two samples of a Job series, so the 5-minute panels of the ai-spend dashboard show only the Service.rate(...[1h])sometimes sees two samples and extrapolates, so the rolling 1-hour lines show spikes that the 5-minute lines do not (fix(monitoring): read AI spend from the gateway counter #4724).- The collector (
deltatocumulative,max_stale: 1h) forgets a Job stream after 1 h with no point, so the next Job starts the stream again, and Prometheus reads a reset (9 resets in 6 h onroadmap-stage).
Expected behavior
- A Job pod exports its metrics at a fixed interval while it runs (the standard is the SDK's
PeriodicExportingMetricReader, default 60 s), and once more when it ends. - A Job that gets SIGTERM (deadline, eviction, node drain) exports before it exits.
- The Service keeps its flush after each round.
Test first: a fake exporter records an export from a long command before the command ends.
Related
- fix(telemetry): a cluster job's usage counters count in increase(), though each job pod exports once #2039 (one series per workload for the Jobs), fix(service): roadmap-service exports its AI usage counters after every lane batch, under one series identity that survives a pod restart #1629 (the Service flush), fix(telemetry): keep one metric stream per workload #4697, fix(monitoring): read AI spend from the gateway counter #4724 (spend from the gateway counter), fix(monitoring): price local savings at the reference model #5914.
Metadata
Metadata
Assignees
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard workscope/telemetryOpenTelemetry tracing spans, Prometheus metrics, and Jaegersource/agentFiled by an agenttype/bugType bug: the code does not do what it mustvalue/highValue High: the delivery of the item matters much
Activity
dan-petty commentedon Nov 16, 2026
Both address the one-sample-per-Job problem, but #5210 fixes counter semantics in increase() while the candidate changes the export mechanism to produce multiple samples.devops-cli-service commentedon Nov 16, 2026
Released in v0.160.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.160.1
devops-cli-service commentedon Nov 16, 2026
Live since 2026-11-16 03:27 UTC