Skip to content

feat(roadmap): metrics for the pipeline outcomes #3069

Closed

Description

@dan-petty

Problem

The roadmap Service records the outcomes of the pipeline in job records and labels. No metric shows the implement outcomes by item class, the repair rounds, the tokens per delivered item, or the same failure class in a row. devops_cli_roadmap_stage_total counts the plans, but it has no repo label, so a reader cannot split the count by repository.

Expected

This item delivers the metrics. #3655 holds the dashboard and the alerts, and it starts after this item.

  • devops_cli_service_implement_jobs_total{repo,item_class,result}: one count for each runner Job that a round reports.
  • devops_cli_service_implement_repair_rounds_total{repo,item_class} and devops_cli_service_implement_tokens_total{repo,item_class}: counters. A panel divides them by the count of delivered items.
  • devops_cli_service_implement_consecutive_failures{repo,class}: a gauge that holds how many stops in a row have this class. A kept state record holds the value over a restart.
  • The label repo on devops_cli_roadmap_stage_total. This item adds no second plans counter.
  • The repair-round count of each run in the job record, because only the runner knows it.

The Service emits the new series from _report in src/devops_cli/roadmap/implement_submit.py, on /metrics through GLOBAL_METRICS.

Acceptance criteria

  • Every new metric has a test that it is emitted.
  • Each new counter has each label set at zero from the start of the Service, as fix(telemetry): Service counters read true across pods and repos #3495 does for the failure counter.
  • No new metric has an issue number in a label. The label class holds only values of FailureClass.
  • A test makes a new Service state from a kept record and reads the same gauge value.
  • A stop of another class and a delivered item each set the gauge of the earlier class to zero.
  • k8s/README.md and docs/TELEMETRY.md list each new metric and its labels.

Moved

Dependencies

Related

#3027 (tracker), #3650 (counts kept work by class and outcome, and overlaps the counters of this item: the item that merges second adds its label to the counter that exists and adds no second counter), #3065 (failure classes), #3066 (budgets that read implement.spend).

Alternatives check of 2026-11-04: partly.
Tool: grafana/grafana (https://github.com/grafana/grafana), AGPL-3.0, last activity 2026-11-04, maintained.

Proposed design

Problem statement

The roadmap Service records pipeline outcomes in job records and labels. It emits no bounded metrics for implement outcomes by item class, repair rounds, tokens per delivered item, or consecutive failures by class. devops_cli_roadmap_stage_total has no repo label. This change adds those metrics and the repo label, and records repair rounds in the job record. The dashboard and alerts stay in #3655.

Acceptance criteria

Requirement: Implement job outcome counter

The roadmap Service SHALL increment devops_cli_service_implement_jobs_total with the labels repo, item_class and result once for each runner Job that a round reports.

Scenario: A reported runner Job counts once

  • WHEN A round reports a runner Job for repository owner/repo, item class feat and result succeeded.
  • THEN The series devops_cli_service_implement_jobs_total{repo="owner/repo",item_class="feat",result="succeeded"} increases by one.

Requirement: Repair rounds counter

The roadmap Service SHALL increment devops_cli_service_implement_repair_rounds_total with the labels repo and item_class by the repair-round count of each reported implement step.

Scenario: Repair rounds add to the counter

  • WHEN A reported implement step records two repair rounds for repository owner/repo and item class feat.
  • THEN The series devops_cli_service_implement_repair_rounds_total{repo="owner/repo",item_class="feat"} increases by two.

Requirement: Token counter

The roadmap Service SHALL increment devops_cli_service_implement_tokens_total with the labels repo and item_class by the token count that the reported runner Job records.

Scenario: Tokens add to the counter

  • WHEN A reported runner Job for repository owner/repo and item class feat records 1,000 tokens.
  • THEN The series devops_cli_service_implement_tokens_total{repo="owner/repo",item_class="feat"} increases by 1,000.

Requirement: Consecutive-failure gauge

The roadmap Service SHALL expose devops_cli_service_implement_consecutive_failures with the labels repo and class, and the gauge SHALL hold the number of stops in a row of that class.

Scenario: A stop increments its class gauge

  • WHEN A reported stop has class tests and the gauge for tests is 1.
  • THEN The gauge devops_cli_service_implement_consecutive_failures{repo="owner/repo",class="tests"} becomes 2.

Requirement: Consecutive-failure gauge persists

The roadmap Service SHALL keep the consecutive-failure gauge value in a state record and SHALL report the same value after a restart.

Scenario: A restart keeps the gauge value

  • WHEN A Service stops with devops_cli_service_implement_consecutive_failures{repo="owner/repo",class="tests"} at 2 and a new Service starts from the same state record.
  • THEN The new Service exposes the same gauge value 2.

Requirement: Different class resets the earlier gauge

The roadmap Service SHALL set the consecutive-failure gauge of a class to zero when a stop of another class follows.

Scenario: A different class resets the earlier gauge

  • WHEN The gauge for class tests is 2 and the next reported stop has class timeout.
  • THEN The gauge for tests becomes 0 and the gauge for timeout becomes 1.

Requirement: Delivered item resets the earlier gauge

The roadmap Service SHALL set the consecutive-failure gauge of a class to zero when a delivered item follows.

Scenario: A delivered item resets the earlier gauge

  • WHEN The gauge for class tests is 2 and a runner Job reports a delivered item.
  • THEN The gauge for tests becomes 0.

Requirement: Plan counter repository label

The roadmap Service SHALL add the label repo to devops_cli_roadmap_stage_total and SHALL NOT add a second plans counter.

Scenario: A staged item carries its repository

  • WHEN A stage round counts a staged item for repository owner/repo.
  • THEN The series devops_cli_roadmap_stage_total{repo="owner/repo",result="staged"} increases by one and no devops_cli_roadmap_pipeline_plans_total series exists.

Requirement: Repair rounds in the job record

The roadmap Service SHALL record the integer repair-round count of each implement step in the item job record from StepOutcome.repair_rounds.

Scenario: A step with repair rounds is recorded

  • WHEN An implement step ends with two repair rounds.
  • THEN The item job record holds the integer 2 for the step's repair-round count.

Requirement: Zero label sets at Service start

The roadmap Service MUST create each new counter label set at zero from the start of the Service.

Scenario: A new Service exposes zero counter series

  • WHEN A Service starts with repository owner/repo and item classes feat and fix.
  • THEN Each new counter exposes a zero series for each known label set before any runner Job is reported.

Requirement: Bounded labels

No new metric SHALL have an issue number in a label, and the label class SHALL hold only values of FailureClass.

Scenario: A failure label uses a bounded class

  • WHEN The Service records a stop with failure class tests.
  • THEN The gauge uses class="tests" and no new metric series has a label whose value is an issue number.

Requirement: Metric emission tests

Every new metric MUST have a test that asserts the Service emits it.

Scenario: A new metric lacks an emission test

  • WHEN The test suite runs over the metric definitions.
  • THEN The suite fails and names the metric without an emission test.

Requirement: Metric documentation

k8s/README.md and docs/TELEMETRY.md SHALL list each new metric and its labels.

Scenario: The docs list a new metric

  • WHEN A documentation test reads the new metric names from the Service.
  • THEN Each name and its labels appear in both k8s/README.md and docs/TELEMETRY.md.

Existing Tool Considered

Grafana (https://github.com/grafana/grafana, AGPL-3.0, maintained, last activity 2026-11-04) covers dashboard rendering and provisioned ConfigMaps. It lacks the pipeline metrics, alert rule evaluation and promtool tests, a failure-class vocabulary and bounded labels, a metric-emission test per metric, a runbook entry per alert, and panel agreement checked against the job record. No existing tool emits the Service metrics. The written cost of the Service instrumentation, state record and tests is about 20k tokens to build, keep and fix, and about 2 days elapsed.

Key questions

  • Which existing metric counts a plan, and does this item need a second plans counter?: No second plans counter is needed. The Service already counts each staged item in devops_cli_roadmap_stage_total by result in emit_stage_results. This item adds the repo label to that counter. (best practice) [sources: src/devops_cli/roadmap/stage.py, src/devops_cli/telemetry/instruments.py, k8s/README.md]
    • Chosen: Extend devops_cli_roadmap_stage_total with repo. It counts the same staged event once and keeps one plans series.
    • Rejected: Add devops_cli_roadmap_pipeline_plans_total. It counts the same event twice and adds a second plans counter.
  • Which transport, names and labels do the new metrics use?: The Service emits them from _report on /metrics through GLOBAL_METRICS. The names use the devops_cli_service_ prefix. The failure label is class. The counters replace histograms, because GLOBAL_METRICS.record_histogram takes no buckets. The existing stage counter stays on OTLP. (best practice) [sources: src/devops_cli/roadmap/implement_submit.py, src/devops_cli/telemetry/metrics.py, tests/prometheus/test_implement_failure_labels.py, k8s/README.md]
    • Chosen: Service metrics path with devops_cli_service_ prefix. It matches the existing failure counter and the Service scrape path.
    • Rejected: OTLP emit with devops_cli_roadmap_pipeline_ names. It mixes transports and the histogram path has no buckets for tokens.
    • Rejected: Use failure_class as the label. The existing failure counter and its test use class.
  • How does the consecutive-failure gauge stay correct across a Service restart?: Use a kept state record like FailureLedger: read it when the Service starts, write it at each gauge change, and report the gauge at start. Alerts read max by (repo, class). (best practice) [sources: src/devops_cli/roadmap/run.py, src/devops_cli/roadmap/implement_submit.py, k8s/README.md]
    • Chosen: Kept state record. It holds the gauge over a restart and matches the failure ledger pattern.
    • Rejected: In-memory gauge only. Each pod has its own series and a restart starts at zero, so three in a row never shows.
  • Where does the Service get the repair-round count for the job record?: It reads StepOutcome.repair_rounds in src/devops_cli/roadmap/implement_step.py:355 and writes the integer to the item job record when _report runs. [sources: src/devops_cli/roadmap/implement_step.py:355, src/devops_cli/roadmap/implement_submit.py, src/devops_cli/roadmap/store.py]
  • Where does the Service get the token count for a reported Job?: It reads the token count from the job record key implement.spend that the runner writes. feat(roadmap): cost and token budgets per item and per day #3066 budgets read the same key. [sources: src/devops_cli/roadmap/implement_run.py, src/devops_cli/roadmap/implement_submit.py, docs/ROADMAP_WORKFLOW.md]
  • Does the failure-class vocabulary need a person decision?: No. FailureClass in src/devops_cli/roadmap/failure.py holds the classes, and implement.failure records the class of a stop. [sources: src/devops_cli/roadmap/failure.py, src/devops_cli/roadmap/implement_submit.py, tests/prometheus/test_implement_failure_labels.py]
  • Which labels separate item class from failure class?: Use item_class for the Conventional Commit type of the item. Use class for the FailureClass value. Do not use an item label, because an issue number gives unbounded series. (best practice) [sources: k8s/README.md, docs/ROADMAP_WORKFLOW.md, src/devops_cli/roadmap/failure.py, tests/prometheus/test_implement_failure_labels.py]
    • Chosen: Separate item_class and class labels. Each alert and panel selects one dimension, and both labels stay bounded.
    • Rejected: One class label. It mixes item types with failure classes, so the alerts cannot select one dimension.
    • Rejected: An item label with the issue number. An issue number gives unbounded series.
  • Does this item overlap feat(roadmap): count kept work by failure class and outcome #3650, and how do the counters merge?: Yes. devops_cli_service_implement_failures_total has class and no outcome. The new jobs counter has result and no class. The item that merges second adds the label it needs to the counter that exists and adds no second counter. This item adds no kept-work outcome. (best practice) [sources: src/devops_cli/roadmap/implement_submit.py, k8s/README.md]
  • Are the dashboard and alerts part of this item?: No. This item delivers the metrics only. feat(roadmap): a dashboard and alerts for the pipeline #3655 holds the dashboard, its GitOps provision, its panel checks, the alerts and their runbook entries. (best practice) [sources: k8s/monitoring/dashboards/kustomization.yaml, k8s/monitoring/prometheus-values.yaml, k8s/README.md]
  • Does this item fit one pull request after the dashboard and alerts move to feat(roadmap): a dashboard and alerts for the pipeline #3655?: Yes. The metrics, the job-record field and their tests change src/devops_cli/roadmap/ and its tests, and fit one pull request. (best practice) [sources: src/devops_cli/roadmap/implement_submit.py, tests/roadmap/test_roadmap_implement_submit.py, k8s/README.md]
    • Chosen: One pull request for the metrics. The remaining change is bounded to the Service metrics and their tests.
    • Rejected: One pull request for metrics, dashboard and alerts. The original scope is more than 2,000 added lines.
  • Does feat(telemetry): stuck-item age metrics and one alert for the roadmap #2919 still provide the stuck-item metrics that this item must use?: No. feat(telemetry): stuck-item age metrics and one alert for the roadmap #2919 is closed. feat(telemetry): measure how long roadmap items wait in each state #3601 delivered devops_cli_roadmap_item_age_seconds, devops_cli_roadmap_oldest_item_number, devops_cli_roadmap_claim_age_seconds and the RoadmapServiceItemStuck alert. A panel can read them, and no second state alert is necessary. [sources: k8s/README.md, k8s/monitoring/prometheus-values.yaml]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#3495

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 1, 2026
  2. dan-petty commented on Nov 1, 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/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The pipeline works without the dashboard; this improves observability but does not block delivery.
    • Value: Medium. Operators gain visibility into pipeline health and early warning, but the core pipeline functions without it.
    • Effort: Medium. The work spans emitting several metrics, authoring a Grafana dashboard JSON, configuring alerts, writing metric-emission tests, and a runbook entry.
    • Related: feat(roadmap): an enterprise-grade plan and implement pipeline (tracker) #3027, which asks for a different change. Both belong to the pipeline tracker; #3027 is the umbrella for the whole pipeline while the candidate is one deliverable (dashboards and alerts) within it.
  3. added
    priority/p2-medium
    on Nov 1, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  5. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

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

    Moved to new items: #3162.

  6. dan-petty commented on Nov 2, 2026

    @dan-petty
    OwnerAuthor

    This item cannot be built as written. A read of the code at main (5dc4da7c) found these causes. They come from a read-only check by an agent; no code was changed, and I did not repeat the checks.

    1. Acceptance criterion 4 (panel agreement) cannot be tested. devops roadmap explain (src/devops_cli/roadmap/explain.py, spec roadmap-explain) prints yes or no and the first rule that stops the stage job and the implement job. It reports no outcome counts, durations, repair rounds or tokens, so no panel value can equal an explain value. Its docstring says it does not read the Service's failure ledger.
    2. Time in a status and the stuck-item alert duplicate feat(telemetry): stuck-item age metrics and one alert for the roadmap #2919. feat(telemetry): stuck-item age metrics and one alert for the roadmap #2919 asks for the age gauge, one alert and a panel. Its source of status age is a design choice that feat(telemetry): stuck-item age metrics and one alert for the roadmap #2919 owns. Building it here gives two sets of state-age metrics and two alerts.
    3. The defect rate of plans is already feat(roadmap): measure plan defect rate after plan verification #3162.
    4. The item label is unsafe. An issue number as a label gives unbounded series. The repository bounds labels (bounded_label, fix(ai): bound the number of prewarm model label values #2742). Each metric needs a bounded set such as item_class or result.
    5. The label sets cannot be joined. The implement job runs as a runner Job with OTEL_SERVICE_NAME=devops-cli-job (k8s/devops/cronjob-runner.yaml), and the Service uses roadmap-service (k8s/devops/roadmap-service/deployment.yaml). Every existing roadmap alert selects job="roadmap-service". A counter from the runner and a gauge from the Service do not join without ignoring(job, instance) and matching labels. Repair rounds exist only in the runner (StepOutcome.repair_rounds, implement_step.py:355). The job record's implement.spend holds only requests and tokens.
    6. Failure class does not exist. The only candidate is implement.stopped, the step name. Nothing records three failures in a row of one class. The Service's failure counts are per job and row, not per item.
    7. The reuse list is partly wrong. devops_cli_service_jobs_total counts Service rounds, not implement outcomes. No instrument has item_class or failure_class.
    8. Test paths in the issue do not exist. The real files are tests/prometheus/test_k8s_monitoring_alerting.py, tests/prometheus/test_k8s_monitoring_dashboards.py and tests/telemetry/test_telemetry_instruments.py.

    A buildable scope needs an owner decision on the failure-class vocabulary. A possible shape: drop the panel-agreement requirement; leave state age to #2919 and the plan defect rate to #3162; let the Service be the only emitter, from _report in implement_submit.py, with bounded labels (item_class, result or failure_class); add the repair-round count to the job record; write the alerts with job="roadmap-service" and promtool tests; add the dashboard to the grafana-devops-cli-dashboards entry and one runbook entry for each alert.


    Generated by Claude Code

  7. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    The stage job returned the item to New. The premise of the issue does not hold at the staging commit, so the job planned no change and opened no pull request.

    Evidence:

    placeholder

  8. removed
    status/ready
    on Nov 2, 2026
  9. 16 remaining items

  10. added
    status/new
    on Nov 5, 2026
  11. added
    status/ready
    and removed
    status/new
    on Nov 5, 2026
  12. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

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

  13. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards: three issues of #3027 add metrics with the labels repo, row, step and result:

    • 'feat(telemetry): measure the seconds of each row';
    • 'feat(telemetry): step seconds and a gate counter for the stage row';
    • 'feat(telemetry): an intake outcome counter and implement step seconds'.

    Keep the label scheme of this item: repo, item_class, result and class. Use the label names repo, row and result in the same way in all items, so a dashboard (#3655) joins them. #3666 uses repo and lane for a round that fails before its first row.

    Do not add a second stage counter. The step issues take the row name as an argument and add no item_class label.

  14. added 2 commits that reference this issue on Nov 8, 2026
    4ed5b79
    77676b7
  15. added
    status/in-review
    and removed
    status/ready
    on Nov 8, 2026
  16. removed
    status/in-review
    on Nov 8, 2026
  17. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-08 22:36 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/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions