Repository navigation
Description
Problem
Stage has one metric, devops_cli_roadmap_stage_total, with the label result only (stage.py, emit_stage_results). No metric shows how long the steps of a stage round take. No counter shows which gate refused a plan. check_proposal joins the problems of all gates, and the gate name is lost.
Expected
Add one histogram devops_cli_roadmap_step_seconds with the labels repo, row, step and result. The step values come from StepName (roadmap/failure.py). The row name is passed as an argument, as tool_metrics.start_run(row=...) takes it. So no shared scope is needed.
In this issue row is stage. The issue #4067 reuses the histogram for the implement row.
StepName members for the stage:
planandapplyexist from the issue feat(roadmap): record the failure class and step of a stage item #4056.- This issue adds
select,gateandreview.
What each step times:
select:read_stage_selection.plan: the model calls of the planner for one item.gate: the calls of the gates for one item.review: the model review of the verifier.apply: the write of one item.
result has two values: ok and error.
Series count: 1 repo x 1 row x 5 steps x 2 results = 10 series, times the histogram buckets.
Add the counter devops_cli_roadmap_stage_gate_refusals_total with the labels repo and gate. The planner calls check_gates where it calls check_proposal, and adds 1 for each gate that found a problem. The value of gate is a ProposalGate value. Series count: 14 gates x 1 repo = 14.
Document both series in docs/TELEMETRY.md. State the series counts there.
No live model run (AGENTS.md rule 13).
Acceptance criteria
-
uv run pytest tests/telemetry/test_roadmap_stage_steps.py -k step_label- a stage round emits a step sample for select, plan, gate, review and apply. -
uv run pytest tests/telemetry/test_roadmap_stage_steps.py -k gate_refusal- a refused plan increments the counter of its gate name, and only that gate. -
uv run pytest tests/telemetry/test_roadmap_stage_steps.py -k step_names- the step values are members ofStepName. No other value appears. -
grep -q 'devops_cli_roadmap_step_seconds' docs/TELEMETRY.md && grep -q 'devops_cli_roadmap_stage_gate_refusals_total' docs/TELEMETRY.md- the documentation lists both series (it prints nothing today).
Every command above fails on the unchanged code. The pull request cites the fail-to-pass run (devops ci fail-to-pass --base <ref>).
Feasibility
I read these files at origin/main: stage.py (emit_stage_results, _settle, read_stage_selection), stage_change.py (check_gates, check_proposal, ProposalGate), roadmap/tool_metrics.py, telemetry/instruments.py and docs/TELEMETRY.md. I checked that check_proposal calls check_gates and joins its lists. I did not run the code. The change makes no GitHub request.
Existing tool considered
telemetry/instruments.py (emit), tool_metrics.py as the pattern, and the OpenTelemetry instruments that exist. No new library.
Cost
Build: about 50k tokens and 2.5 h. Keep: about 3k tokens per quarter. Fix: about 10k tokens and 0.5 h.
Related
Part of #3027. #3069, #3650, #3655, #3162, #3566. Order: after the issues #4056 and #4064. All of them change stage.py or the telemetry files.
Proposed design
Problem statement
The stage row emits one counter, devops_cli_roadmap_stage_total, with the result label only. It shows neither the time of each stage step nor the gate that refused a plan. Add a step histogram and a gate-refusal counter, and document both.
Acceptance criteria
Requirement: Step histogram instrument
The telemetry instruments SHALL declare devops_cli_roadmap_step_seconds as a histogram with the labels repo, row, step and result.
Scenario: Histogram declaration
- WHEN A test reads the
INSTRUMENTSentry fordevops_cli_roadmap_step_seconds. - THEN The entry is a histogram with unit
sand the labelsrepo,row,stepandresult.
Requirement: Step names
StepName SHALL hold the members select, plan, gate, review and apply, and the step label MUST use only those values.
Scenario: Step label values
- WHEN A stage round emits step samples.
- THEN Every
stepvalue is a member ofStepName, and no other value appears.
Requirement: Stage step samples
A stage round SHALL emit one devops_cli_roadmap_step_seconds sample for each of select, plan, gate, review and apply with row=stage.
Scenario: Stage round step samples
- WHEN A test runs a stage round with a fake model client and no live model call.
- THEN The histogram has one sample for each step, and each sample has
row=stageandresult=ok.
Requirement: Failed step sample
A step that raises an exception SHALL emit its devops_cli_roadmap_step_seconds sample with result=error.
Scenario: Failed plan step
- WHEN A fake planner raises an error during the
planstep. - THEN The histogram has a
plansample withrow=stageandresult=error.
Requirement: Gate refusal counter
The stage planner SHALL call check_gates in place of check_proposal and increment devops_cli_roadmap_stage_gate_refusals_total once for each ProposalGate that reports a problem, with the gate name in gate and the repository in repo.
Scenario: Refused plan
- WHEN A test runs the planner with two gates that report a problem and one gate that reports none.
- THEN The counter increases by 1 for each of the two gate names and by 0 for the gate that reports none.
Requirement: Telemetry documentation
docs/TELEMETRY.md SHALL list devops_cli_roadmap_step_seconds and devops_cli_roadmap_stage_gate_refusals_total with their labels, types and series counts.
Scenario: Documentation entries
- WHEN A test searches
docs/TELEMETRY.mdfor both metric names. - THEN Both names are present, and the entries state 10 histogram series and 14 counter series for one repository.
Existing Tool Considered
No alternatives check has run. The OpenTelemetry Python SDK is open and maintained, and it covers histograms and counters. It lacks the stage-specific step timing and gate-refusal names and labels, so the change adds two instruments through src/devops_cli/telemetry/instruments.py. No new library is needed.
Key questions
- Which open tool provides the histogram and counter instruments?: The OpenTelemetry Python SDK provides both instrument kinds. The project already declares and sends them through
src/devops_cli/telemetry/instruments.py. No new library is needed. [sources: docs/TELEMETRY.md, src/devops_cli/telemetry/instruments.py] - Where does the change declare and send the two metric names?: Declare
devops_cli_roadmap_step_secondsanddevops_cli_roadmap_stage_gate_refusals_totalinINSTRUMENTSinsrc/devops_cli/telemetry/instruments.py. Send each observation withemit(). [sources: docs/TELEMETRY.md, src/devops_cli/telemetry/instruments.py] - How many Prometheus series does the step histogram add?: The histogram adds 10 series: 1 repo x 1 row x 5 steps x 2 results. Prometheus 3 stores it as a native histogram, so bucket series do not multiply the count. [sources: docs/TELEMETRY.md]
- Where does the gate-refusal counter read the gate name?: The stage planner calls
check_gatesin place ofcheck_proposal. It iterates over the per-gate results, increments the counter for each gate with a problem, and joins the lists for the retry. (best practice) [sources: src/devops_cli/roadmap/stage/stage_change.py, docs/roadmap/plan-check.md]- Chosen: Call check_gates in the planner. It keeps the gate name and counts only stage planner refusals.
- Rejected: Instrument check_gates. It also counts refusals from plan_recheck and stage_request.
- Rejected: Instrument check_proposal. It joins the lists and loses the gate name.
- Which step names does this issue add?: Add
select,gateandreviewtoStepName. Keepplanandapplyfrom issue feat(roadmap): record the failure class and step of a stage item #4056. [sources: src/devops_cli/roadmap/failure.py, openspec/changes/archive/2026-11-08-4056-record-the-failure-class-and-step/specs/roadmap-failure-taxonomy/spec.md] - What does each step time?:
selecttimesread_stage_selection;plantimes the planner model calls for one item;gatetimes the gate calls for one item;reviewtimes the verifier model review;applytimes the write of one item. [sources: src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/stage/stage_change.py]
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(telemetry)scope of the title gives the scope.Observability improvement for operators; no user-facing defect or security risk.Gives operators step-level timing and gate refusal visibility, aiding tuning and debugging.Adds one histogram, one counter, three StepName values, stage.py changes, and a docs update; about 2.5 h per the body.Both add timing histograms to the roadmap telemetry, but #4058 measures the full row duration while this candidate measures individual steps within a stage row.devops-cli-service commentedon Nov 8, 2026
Status set to Ready at ba4679c (see proposed design in issue body).
devops-cli-service commentedon Nov 8, 2026
Released in v0.93.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.93.0
devops-cli-service commentedon Nov 8, 2026
Live since 2026-11-08 20:02 UTC
feat(telemetry): count intake outcomes and time implement steps (#4187)