Repository navigation
Description
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 counterdevops_cli_roadmap_items_closed_total{repo, reason}with reasoncompleted,not_plannedorduplicate, fromissuescloseddeliveries 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
closeddelivery only when itsSET NXofroadmap: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
issuescloseddelivery of a roadmap item adds 1 to the reason of itsstate_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
- feat(roadmap): a dashboard and alerts for the pipeline #3655 (the pipeline dashboard).
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
issuescloseddelivery carries an issue with the labelpriority/p1-highandstate_reasoncompleted - THEN the counter has the value 1 with the
repoof that repository and thereasoncompleted
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
issuescloseddelivery carries an issue whose labels hold nopriority/prefix - THEN no sample of
devops_cli_service_roadmap_items_closed_totalchanges
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/aando/b - THEN the counter has a 0 sample for each of
completed,not_planned,duplicateandunknownon 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
issuescloseddelivery 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
issuescloseddelivery carries an issue with the labelpriority/p1-highandstate_reasonnull - THEN the counter has the value 1 with the
repoof that repository and thereasonunknown
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
issuescloseddelivery carries apriority/p1-highissue andsender.loginequal to the App bot - THEN the counter has the value 1 with the
repoof 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
shortqueriesdevops_cli_service_roadmap_items_closed_totalwithjob=~"$job", grouped byrepoandreason
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, afterservice_manager.delivery_cache.check_and_addand 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;WebhookIssuegainslabelsandstate_reason, which it ignores today. The rule is recorded: an item is an issue with apriority/*label, and the values arepriority/p0-critical,priority/p1-high,priority/p2-mediumandpriority/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_reasonuse?: The reasonunknown, and any value other thancompleted,not_plannedorduplicatealso counts asunknown, so the label stays a bounded set. GitHub'sstate_reasonmay benull(and may bereopenedwhile 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_reasonvalue. A value that GitHub chooses would add a series for each value, which ADR 0009 forbids for sender text.
- Chosen:
- Where does the counter start at 0?: In
create_webhook_router, throughGLOBAL_METRICS.prime_counter, with one label set for each managed repository and each reason. The router already primesdevops_cli_service_webhook_deliveries_totalthis way, andprime_countercreates 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 byCONST_SERVICE_METRIC_ROADMAP_ITEMS_CLOSEDinsrc/devops_cli/config/constants.pybesideCONST_SERVICE_METRIC_WEBHOOK_DELIVERIES. The counter is a/metricsseries of the Service: the project records that each Service counter is primed at zero and charted in the "Roadmap Service" row, and a name outsidedevops_cli_service_*would break both. The body'sdevops_cli_roadmap_items_closed_totalis the OTLP family ofINSTRUMENTSthatemit()sends, not a/metricsseries thatprime_countercan 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/metricsseries, primed at zero throughGLOBAL_METRICS, and the row test that everyCONST_SERVICE_METRIC_*name has a query then covers it. - Rejected: The body's
devops_cli_roadmap_items_closed_totalinINSTRUMENTS. It moves the counter to the OTLP path thatemit()sends and that noprime_countercall creates, so the zero-at-start requirement and the/metricsscrape would not hold.
- Chosen:
- Does an
issuescloseddelivery reach the duplicate check?: Yes.CONST_ROADMAP_WEBHOOK_EVENTSholdsissues, so the roadmap consumer subscribes to the event, and_routeruns 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 NXofroadmap:v1:delivery:<id>replaces the in-memory check there without moving the count. The router runs one replica today, because the Deployment isRecreate, 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 querysum 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]- Chosen: This issue adds the panel to the existing row. The row test fails on a Service counter with no panel, the panel is one JSON block, and the body asks for it now.
- Rejected: Defer the panel to feat(roadmap): a dashboard and alerts for the pipeline #3655 with the
deferred_metricsexemption. That exemption exists for the metrics of feat(roadmap): metrics for the pipeline outcomes #3069, and using it here leaves the counter unread until feat(roadmap): a dashboard and alerts for the pipeline #3655 lands for a panel of about ten lines. - Rejected: Drop the panel. The body requires it, and the row test fails without it.
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
dan-petty commentedon Nov 11, 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.(roadmap)scope of the title gives the scope.It feeds the pipeline dashboard (#3655) but is a supporting metric, not a user-facing feature on its own.It gives operators throughput and closure-reason visibility that the dashboard needs, but no user directly consumes the counter.One counter in the existing webhook router with a SET NX dedup guard; the body estimates about 2 hours to build.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.devops-cli-service commentedon Nov 12, 2026
Status set to Ready at c3130a3 (see proposed design in issue body).
Moved to new items: #4895.
devops-cli-service commentedon Nov 13, 2026
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/reasonlabel 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)
Covers:
repo,reason) exposed on/metricsGLOBAL_METRICSfor its Service countersLacks:
priority/*labels or thestate_reasonvalues completed/not_planned/duplicatestate_reasonto a boundedunknownreasonSET NXofroadmap:v1:delivery:<id>)issuescloseddelivery that the router receivesTools considered:
Searches run:
Sources:
Checked on 2026-11-13. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Released in v0.172.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.172.0
devops-cli-service commentedon Nov 17, 2026
Live since 2026-11-17 12:22 UTC