Repository navigation
Description
Problem or Motivation
Each runner Job exports its metrics with instance=<pod name>, so each Job makes new series, and each series starts at its first value. increase() and rate() then lose the count up to the first sample. The operations review measured this over 7 days:
- For
devops_cli_ai_requests_total{job="devops-cli-job"}, sum(last_over_time) = 83, but sum(increase) = 1.5. - 37 of 92 Job series of
devops_cli_ci_checks_totalhave exactly one sample.
Dashboards that use increase() on Job counters show values that are too low.
Proposed Solution & Architectural Design
-
Check the premise again with one PromQL query. fix(telemetry): keep one metric stream per workload #4697 puts all runner Jobs in one metric stream (
service.instance.id=devops-cli-job). After that change, a new Job still starts its counters at 0, and a new total that is not lower than the old one is not seen as a reset. So check the premise on the state after fix(telemetry): keep one metric stream per workload #4697 when fix(telemetry): keep one metric stream per workload #4697 is merged first. -
Then do one of these:
- Emit a zero sample for each known label set when a Job starts. This is the usual fix for a counter that starts late.
- Change the Job dashboards and alerts to sum(last_over_time(...)) for each instance.
Choose the first when the exporter supports it.
Files: src/devops_cli/telemetry/instruments.py, tests/telemetry/test_instruments.py.
Target Subsystem
Kubernetes & Minikube Automation (Grafana dashboards and telemetry).
Existing Tool Considered
The OpenTelemetry SDK exporter that the project uses. Cost: about 0.3M model tokens and half a day.
Acceptance Criteria
- A test with a fake exporter shows a zero sample before the first increment of a Job counter.
- Real data: a PromQL comparison of sum(increase) and sum(last_over_time) for one Job counter over the 7 days after the deploy, in the pull request comment, differs by less than 5 %.
Dependencies
None. Check the premise against the state of #4697.
Related
- Tracker: feat(roadmap): track the shared command gate #5199. The command gate design found this, because its rollout counts cannot come from these counters.
- fix(telemetry): keep one metric stream per workload #4697: one metric stream for each workload.
- feat(roadmap): report the live shadow bar of the command gate from Loki #5208: reads its rollout counts from Loki because of this problem.
Source: #5199
Alternatives check of 2026-11-29: in-use.
The repository already uses this tool.
Tool: open-telemetry/opentelemetry-python (https://github.com/open-telemetry/opentelemetry-python), Apache-2.0, last activity 2026-11-28, maintained.
Reason: Searches returned only unrelated pages; the fact reads confirm the OpenTelemetry Python SDK that the project already uses, whose Counter.add accepts a zero amount with explicit attributes, so a Job can open each label set at zero before its first increment.
Covers:
- Counter.add with amount zero records a data point for given attributes
- Series exists at zero before the first increment, so increase counts it
- Runs through the exporter already wired into the runner Job
- Same zero-sample pattern the repository already uses elsewhere
Lacks:
- No automatic enumeration of label sets; the Job must pass each known set
- Cannot backfill series emitted before the change, so history stays low
- No dashboard or alert change; panels using increase stay wrong until zero samples land
- The live PromQL comparison after deploy stays a manual check
Proposed design
Problem statement
Runner Job counters make a new series for each Job. The first sample of a new series starts at the first count. increase() and rate() lose the count before that sample, so dashboards show values that are too low. The change emits a zero sample for each known label set before the first increment. A follow-up verifies the live result after deploy.
Acceptance criteria
Requirement: Zero sample before first increment
A runner Job SHALL emit a zero sample for each known label set before the first increment of that counter.
Scenario: Fake exporter sees the zero sample first
- WHEN A test starts a runner Job counter with two known label sets and adds the first increment to each.
- THEN The fake exporter records a zero sample for each label set before its first increment sample.
Requirement: Zero sample carries the first increment attributes
The zero sample MUST carry the same attributes as the first increment of the counter.
Scenario: Attributes match between zero and first increment
- WHEN A test starts a runner Job counter with a known label set and adds the first increment.
- THEN The fake exporter records the same attribute set on the zero sample and on the first increment sample.
Requirement: No zero sample for an unused label set
The runner Job MUST NOT emit a zero sample for a label set that it does not use in its run.
Scenario: Unused label set stays absent
- WHEN A test starts a runner Job with no known label set for a counter.
- THEN The fake exporter records no zero sample for that counter.
Existing Tool Considered
The alternatives check in the issue body records verdict in-use for open-telemetry/opentelemetry-python (Apache-2.0, maintained). That check lists what the tool covers and lacks. The proposal supplies the known label sets from the Job run and calls Counter.add(0, attributes) before the first increment. The deferred live check measures the result after deploy.
Key questions
- Which route fixes the missing first count: a zero sample at Job start or a dashboard
last_over_timequery?: Emit a zero sample for each known label set at Job start. The OpenTelemetry SDK recordsCounter.add(0, attributes), and the repository already uses a zero sample to keep a series forROADMAP_TOOL_CALLS_TOTAL. (best practice) [sources: src/devops_cli/telemetry/instruments.py:444]- Chosen: Zero sample at Job start. The SDK supports
Counter.add(0, attributes), and the repository already uses a zero sample to keep a series forROADMAP_TOOL_CALLS_TOTAL. - Rejected: Dashboard
last_over_timequery. It needs a live inventory of every Job series and changes each panel and alert.
- Chosen: Zero sample at Job start. The SDK supports
- Which label sets does the Job use for the zero samples?: The Job uses the label sets that it knows for its run. The helper takes them from the Job configuration. The Job does not enumerate every possible label set. (best practice) [sources: src/devops_cli/telemetry/instruments.py]
- Chosen: Label sets from the Job run. The Job knows the labels that it will use, and the zero sample repeats on the first increment.
- Rejected: All possible label sets. A zero sample for a label set that live traffic never repeats makes a series that never grows.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Both fix telemetry counter correctness for runner Jobs; #4697 fixes stream identity, the candidate fixes the first-sample loss in increase().dan-petty commentedon Nov 15, 2026
The item cannot be completed in a pull request: acceptance criterion 2 reads live Prometheus data over the 7 days after a deploy, and the pull request comment must hold the comparison.
sum(increase(...))againstsum(last_over_time(...))for one Job counter, within 5 %.main. The stream now holdsservice.instance.id=devops-cli-job, but a new Job still starts at 0, so the reset rule does not see it.No code is written before a person measures the current series set and chooses the route on that data. A person then runs the change, deploys it, and posts the 7-day comparison on this item.
devops-cli-service commentedon Nov 17, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
devops-cli-service commentedon Nov 19, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (6)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 19, 2026
Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC