Skip to content

feat(roadmap): count closed items per repository and reason #4580

Closed

Description

@dan-petty

Problem or Motivation

No metric counts the roadmap items that close, by repository and by reason. The pipeline dashboard (#3655) needs it for throughput and for the share of items closed as not planned or duplicate.

Proposed Solution & Architectural Design

  • In the webhook router (src/devops_cli/server/routes/webhooks.py): a counter devops_cli_roadmap_items_closed_total{repo, reason} with reason completed, not_planned or duplicate, from issues closed deliveries of roadmap items.
  • The counter starts at 0 for each repository and reason when the router starts.
  • A repeated delivery adds nothing. Before "feat(service): share the GitHub budget and holds in Valkey" the in-memory delivery cache drops it; after it, the router counts a closed delivery only when its SET NX of roadmap:v1:delivery:<id> succeeds, so 2 router replicas count each delivery once.
  • The panel text says that a lost delivery is not counted.

Target Subsystem

SDLC, Git & PR Governance (roadmap Service webhook router).

Existing Tool Considered

No tool counts closed issues without a GitHub request; the router already receives each closed delivery. Cost: about 150,000 tokens and 2 hours to build, about 5,000 tokens a month to keep, about 20,000 tokens to fix.

Acceptance Criteria

  • An issues closed delivery of a roadmap item adds 1 to the reason of its state_reason; an issue with no roadmap label adds nothing.
  • The counter starts at 0 for each repository and reason when the router starts.
  • A repeated delivery adds nothing.
  • The pipeline dashboard shows closed items by repository and reason.

Dependencies

Source: #4517

Proposed design

Problem statement

The roadmap counts no closed items, so the pipeline dashboard (#3655) cannot show throughput or the share of items closed as not planned or duplicate. The webhook router already receives each issues closed delivery, so it can count them with no GitHub request. This change adds a /metrics counter by repository and reason, primes each label set at zero, and charts it in the "Roadmap Service" row of the devops-cli dashboard, which the project requires of every Service series; #3655's dashboard reads the same series later.

Acceptance criteria

Requirement: Count a closed roadmap item

The webhook router SHALL add 1 to devops_cli_service_roadmap_items_closed_total with the labels repo and reason for an issues closed delivery of an issue that holds a priority/* label.

Scenario: A roadmap item closes as completed

  • WHEN a signed issues closed delivery carries an issue with the label priority/p1-high and state_reason completed
  • THEN the counter has the value 1 with the repo of that repository and the reason completed

Requirement: Skip a closed candidate

The router MUST NOT count a closed issue that holds no priority/* label.

Scenario: A candidate closes

  • WHEN a signed issues closed delivery carries an issue whose labels hold no priority/ prefix
  • THEN no sample of devops_cli_service_roadmap_items_closed_total changes

Requirement: Prime the counter at zero

The router SHALL create devops_cli_service_roadmap_items_closed_total at 0 for each managed repository and each reason when it builds its routes.

Scenario: The router starts for two repositories

  • WHEN the webhook router is created for the managed repositories o/a and o/b
  • THEN the counter has a 0 sample for each of completed, not_planned, duplicate and unknown on each repository

Requirement: Count a delivery once

The router MUST count each delivery id at most once in its process.

Scenario: A delivery repeats

  • WHEN the same issues closed delivery id reaches the router twice
  • THEN the counter with that repository and reason is 1

Requirement: Count a close with no reason

The router SHALL use the reason unknown when a closed roadmap item carries no state_reason or a value other than completed, not_planned or duplicate.

Scenario: A roadmap item closes with a null reason

  • WHEN a signed issues closed delivery carries an issue with the label priority/p1-high and state_reason null
  • THEN the counter has the value 1 with the repo of that repository and the reason unknown

Requirement: Count a close by the App bot

The router SHALL count a closed roadmap item whose sender.login is the App bot.

Scenario: The jobs close a roadmap item

  • WHEN a signed issues closed delivery carries a priority/p1-high issue and sender.login equal to the App bot
  • THEN the counter has the value 1 with the repo of that repository and the reason of the issue

Requirement: Panel for closed items

The dashboard k8s/monitoring/dashboards/devops-cli.json SHALL chart devops_cli_service_roadmap_items_closed_total by repo and reason in the row "Roadmap Service".

Scenario: The dashboard row queries the counter

  • WHEN the dashboard test reads the row "Roadmap Service" of k8s/monitoring/dashboards/devops-cli.json
  • THEN a panel with the unit short queries devops_cli_service_roadmap_items_closed_total with job=~"$job", grouped by repo and reason

Existing Tool Considered

The open, maintained library is prometheus_client 0.26.0 (pyproject.toml:73), which the project already uses through GLOBAL_METRICS (src/devops_cli/telemetry/metrics.py:103). It lacks the repo and reason label sets, the bounded reason values and the zero priming for this counter, and this change adds them. No library counts closed issues on its own, because the count needs the delivery that the router receives. The added code is one constant, one label-set helper, one counting function, the two payload fields (labels, state_reason) and one panel, with tests: about 25,000 tokens and 45 minutes to build, about 1,000 tokens a month to keep, and about 5,000 tokens to fix. The body's 150,000 tokens cover a new metrics path, which this change does not build.

Key questions

  • Where does the router count a closed roadmap item?: In _route, after service_manager.delivery_cache.check_and_add and before _hand_to_consumers. The counter then sees each delivery once, and it sees the closes that the roadmap jobs make, which the consumer refuses as the App bot's own write. (best practice) [sources: src/devops_cli/server/routes/webhooks.py:553, src/devops_cli/server/routes/webhooks.py:567, src/devops_cli/server/routes/webhooks.py:569, src/devops_cli/server/routes/webhooks.py:328]
    • Chosen: Router level, after the duplicate check. The counter sees every closed delivery once, including the closes that the jobs make as not planned or duplicate.
    • Rejected: In the roadmap consumer deliver. The consumer refuses the App bot's own writes (refuse_own_write), so the items that the jobs close would not count.
    • Rejected: In the scoped update. A scoped update runs only for some events and after the listing snapshot, so it misses closes and costs a store read.
  • How does the router know that a closed issue is a roadmap item?: It matches the priority/ prefix in the labels of the issue in the signed payload; WebhookIssue gains labels and state_reason, which it ignores today. The rule is recorded: an item is an issue with a priority/* label, and the values are priority/p0-critical, priority/p1-high, priority/p2-medium and priority/p3-low. (best practice) [sources: CONTEXT.md:12, docs/adr/0001-github-is-the-roadmap-source.md:3, src/devops_cli/config/constants.py:3662, src/devops_cli/models/webhooks.py:24]
    • Chosen: Labels in the webhook payload. The delivery already carries the issue, so the count costs no GitHub request and no rate-limit budget.
    • Rejected: A GitHub API read of the issue. It adds one request for each closed delivery against the hourly budget, and the router holds no issue cache.
  • Which reason does a close with no state_reason use?: The reason unknown, and any value other than completed, not_planned or duplicate also counts as unknown, so the label stays a bounded set. GitHub's state_reason may be null (and may be reopened while an issue is open), so a raw value would grow the series with text that GitHub chooses. (best practice) [sources: openspec/changes/archive/2026-10-29-1658-issues-close-reason/proposal.md:38, src/devops_cli/roadmap/stores/store.py:98, src/devops_cli/config/constants.py:1688, docs/adr/0009-one-webhook-router-delivers-each-event-to-the-consumers-subscribed-to-it.md:12]
    • Chosen: unknown. It keeps the item in the throughput count, states no reason that GitHub did not give, and keeps the label set bounded.
    • Rejected: Drop the delivery. The item closed, so a dropped delivery understates throughput.
    • Rejected: completed. It states a reason that GitHub did not give.
    • Rejected: The raw state_reason value. A value that GitHub chooses would add a series for each value, which ADR 0009 forbids for sender text.
  • Where does the counter start at 0?: In create_webhook_router, through GLOBAL_METRICS.prime_counter, with one label set for each managed repository and each reason. The router already primes devops_cli_service_webhook_deliveries_total this way, and prime_counter creates each child at zero. [sources: src/devops_cli/server/routes/webhooks.py:673, src/devops_cli/telemetry/metrics.py:103, tests/telemetry/test_service_counter_series.py:150]
  • Which name does the counter publish?: devops_cli_service_roadmap_items_closed_total, held by CONST_SERVICE_METRIC_ROADMAP_ITEMS_CLOSED in src/devops_cli/config/constants.py beside CONST_SERVICE_METRIC_WEBHOOK_DELIVERIES. The counter is a /metrics series of the Service: the project records that each Service counter is primed at zero and charted in the "Roadmap Service" row, and a name outside devops_cli_service_* would break both. The body's devops_cli_roadmap_items_closed_total is the OTLP family of INSTRUMENTS that emit() sends, not a /metrics series that prime_counter can create. (best practice) [sources: docs/TELEMETRY.md:37, docs/TELEMETRY.md:65, CONTRIBUTING.md:191, src/devops_cli/config/constants.py:1565, tests/telemetry/test_telemetry_instruments.py:82, openspec/specs/roadmap-service-counters/spec.md:81]
    • Chosen: devops_cli_service_roadmap_items_closed_total. It is the router's /metrics series, primed at zero through GLOBAL_METRICS, and the row test that every CONST_SERVICE_METRIC_* name has a query then covers it.
    • Rejected: The body's devops_cli_roadmap_items_closed_total in INSTRUMENTS. It moves the counter to the OTLP path that emit() sends and that no prime_counter call creates, so the zero-at-start requirement and the /metrics scrape would not hold.
  • Does an issues closed delivery reach the duplicate check?: Yes. CONST_ROADMAP_WEBHOOK_EVENTS holds issues, so the roadmap consumer subscribes to the event, and _route runs the duplicate check before it hands the payload to the consumers. [sources: src/devops_cli/config/constants.py:3622, src/devops_cli/server/routes/webhooks.py:564, src/devops_cli/server/routes/webhooks.py:567]
  • Does the shared Valkey delivery store change this code?: No. The count sits at the duplicate-check call site, so the SET NX of roadmap:v1:delivery:<id> replaces the in-memory check there without moving the count. The router runs one replica today, because the Deployment is Recreate, and 2 replicas at the end of tracker feat(roadmap): move Service work to Workflows and Valkey #4517; the exact count across replicas waits on that change and goes to the deferred issue. (best practice) [sources: src/devops_cli/server/routes/webhooks.py:567, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:41, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:51]
    • Chosen: Count after the duplicate check. The same call site works with the in-memory cache and with the shared store, and the counter is useful with one replica now.
    • Rejected: Wait for the Valkey change. The shared store changes no call site, so the wait buys nothing for this counter.
  • Who delivers the dashboard panel?: This issue adds the panel to the row "Roadmap Service" of k8s/monitoring/dashboards/devops-cli.json, with the query sum by (repo, reason) (increase(devops_cli_service_roadmap_items_closed_total{job=~"$job"}[1h])). The project records that every Service series is charted in that row, so the counter cannot merge without its panel. feat(roadmap): a dashboard and alerts for the pipeline #3655's pipeline dashboard is a later consumer of the same series, not a prerequisite, so this issue no longer waits on feat(roadmap): a dashboard and alerts for the pipeline #3655. (best practice) [sources: openspec/specs/roadmap-service-counters/spec.md:81, tests/grafana/test_grafana_dashboards.py:1080, tests/grafana/test_grafana_dashboards.py:1084, docs/DESIGN.md:259]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-13: in-use.
The repository already uses this tool.
Tool: prometheus-client (https://pypi.org/project/prometheus-client), Apache-2.0 AND BSD-2-Clause, last activity 2026-07-24, maintained.

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 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. It feeds the pipeline dashboard (#3655) but is a supporting metric, not a user-facing feature on its own.
    • Value: Medium. It gives operators throughput and closure-reason visibility that the dashboard needs, but no user directly consumes the counter.
    • Effort: Low. One counter in the existing webhook router with a SET NX dedup guard; the body estimates about 2 hours to build.
    • Related: feat(roadmap): the roadmap job tallies each release's joins, descopes and trims by reason, and reports them in its plan and as gauges #1126, which asks for a different change. Both add roadmap metrics broken down by reason, but #1126 tallies joins, descopes, and trims per release while this candidate counts closed items per repository and reason.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. added
    status/ready
    and removed
    status/new
    on Nov 12, 2026
  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

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

    Moved to new items: #4895.

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

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches surfaced no tool that counts closed issues by repository and reason, so nothing covers the counting itself. The library the issue already names, prometheus_client 0.26.0, supplies the counter type, the repo/reason label sets and zero-valued child series, but the roadmap-specific counting, delivery de-duplication and dashboard panel have to be written in the router.

    The repository already uses this tool.

    Tool: prometheus-client (https://pypi.org/project/prometheus-client)

    • License: Apache-2.0 AND BSD-2-Clause
    • Last activity: 2026-07-24
    • Maintained: yes

    Covers:

    • Counter metric type with arbitrary label sets (repo, reason) exposed on /metrics
    • Child series that can be created at 0, so the counter starts at 0 per repository and reason
    • The library the project already uses through GLOBAL_METRICS for its Service counters

    Lacks:

    • No knowledge of roadmap items, priority/* labels or the state_reason values completed/not_planned/duplicate
    • No mapping of a missing or unexpected state_reason to a bounded unknown reason
    • No webhook delivery-id de-duplication (the SET NX of roadmap:v1:delivery:<id>)
    • No counting of closed issues on its own; it needs the issues closed delivery that the router receives
    • No Grafana panel or "Roadmap Service" dashboard row

    Tools considered:

    Searches run:

    • Prometheus exporter count GitHub issues closed by state_reason webhook, results: 5
    • prometheus_client Python library counter labels, results: 5
    • github-exporter prometheus issues closed metrics, results: 5
    • prometheus-client PyPI documentation Counter labels initialize zero, results: 5
    • github issue-metrics action report closed issues labels, results: 5
    • prometheus/client_python github Counter metric labels, results: 5

    Sources:

    Checked on 2026-11-13. A person decides what this means for the item. The check changes no label and closes no issue.

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

    @devops-cli-service
    Contributor

    Live since 2026-11-17 12:22 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/lowpriority/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