Skip to content

feat(telemetry): step seconds and a gate counter for the stage row #4066

Closed

Description

@dan-petty

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:

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 of StepName. 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 INSTRUMENTS entry for devops_cli_roadmap_step_seconds.
  • THEN The entry is a histogram with unit s and the labels repo, row, step and result.

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 step value is a member of StepName, 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=stage and result=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 plan step.
  • THEN The histogram has a plan sample with row=stage and result=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.md for 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_seconds and devops_cli_roadmap_stage_gate_refusals_total in INSTRUMENTS in src/devops_cli/telemetry/instruments.py. Send each observation with emit(). [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_gates in place of check_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, gate and review to StepName. Keep plan and apply from 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?: select times read_stage_selection; plan times the planner model calls for one item; gate times the gate calls for one item; review times the verifier model review; apply times 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.

Dependencies

#4064

Activity

  1. added
    source/agent
    type/feature
    scope/telemetry
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/telemetry. The (telemetry) scope of the title gives the scope.
    • Priority: P2-Medium. Observability improvement for operators; no user-facing defect or security risk.
    • Value: Medium. Gives operators step-level timing and gate refusal visibility, aiding tuning and debugging.
    • Effort: Medium. Adds one histogram, one counter, three StepName values, stage.py changes, and a docs update; about 2.5 h per the body.
    • Related: feat(telemetry): measure the seconds of each row #4058, which asks for a different change. 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.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. added
    owner/agent
    on Nov 8, 2026
  5. added
    status/ready
    and removed
    status/new
    on Nov 8, 2026
  6. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at ba4679c (see proposed design in issue body).

  7. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 8, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 8, 2026
  9. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor
  10. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-08 20:02 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/telemetrysource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions