Repository navigation
Description
Problem
The metrics row now spends far more of the GitHub budget, and each rollout likely adds to it.
- Prometheus,
sum by (row)(increase(devops_cli_github_requests_total[1h]))with rowmetrics: about 222 to 305 an hour until the hour that ended 2026-11-05T12:00Z. Then 627 at 13:00Z, 757 at 14:00Z and 1000 in the hour that ended about 14:24Z. - feat(telemetry): measure how long roadmap items wait in each state #3601 merged at 12:05:22Z and adds
item_ages=Trueto the metrics row. Its cache_item_label_timesis per process, so a new pod reads the label events of the open items again. - The Service rolled 5 times from 12:35Z to 14:22Z. The budget is 2000 requests an hour and it holds every row. The log line at 13:24:04Z says 2000 of 2000.
The link to #3601 is likely, from the time and the code. The cost of one new pod was not measured. increase() also extrapolates across pod restarts (#3495), so the totals are approximate.
Expected
The age metrics cost a small, fixed share of the budget, and a rollout does not cost a full read of the open items.
Acceptance criteria
- Measure the requests of the metrics row for one new pod, and state the number in the pull request.
- A test: a new process does not read the events of an item whose
updated_atit already holds in the kept record. - A test: the row reads events for at most a fixed number of items in a round, and the rest wait for later rounds.
- Run live: the metrics row stays near its level before feat(telemetry): measure how long roadmap items wait in each state #3601 over a period with two rollouts.
Existing tool considered
Existing project code: the Service keeps state across a restart (keep_state_record), and the REST If-None-Match read of the GitHub session. No new tool.
Related
Proposed design
Problem statement
The metrics row re-reads the label events of every open item when a new pod starts. The per-process _item_label_times cache makes each rollout spend a large part of the 2000-request hourly budget. The fix persists the cache in the Service state record and caps the item reads in one round.
Acceptance criteria
Requirement: Persist item label times
The metrics row SHALL write each open item's updated_at and label times to the Service state record after a round.
Scenario: State record round trip
- WHEN A metrics round reads label events for an open item and the round completes
- THEN The state record holds the item's
updated_atand label times under the repository and issue key
Requirement: Skip items held in the state record
A new process MUST NOT request label events for an item whose updated_at equals the value in the kept state record.
Scenario: New process with a kept record
- WHEN A new process loads the state record and lists an open item with the same
updated_at - THEN The process makes no label-event request for that item
Requirement: Bound item reads per round
The metrics row MUST read label events for at most _MAX_ITEM_AGE_READS_PER_ROUND items in one round.
Scenario: More stale items than the cap
- WHEN More open items have a changed
updated_atthan the cap in one round - THEN The row reads exactly the cap and keeps the remaining items for later rounds
Requirement: Queue deferred items
The metrics row SHALL read items deferred by the cap before it reads items that were never deferred.
Scenario: Deferred items are read first
- WHEN A round starts with deferred items in the state record and new changed items
- THEN The round reads the deferred items first and fills the rest of the cap with new items
Requirement: Prune closed items
The metrics row SHALL remove a cache entry when the item is no longer in the open item list.
Scenario: Closed item leaves the cache
- WHEN An item in the state record is not in the current open item list
- THEN The next state record write does not hold that item
Requirement: Report measured cost
The change SHALL record the measured GitHub requests for one new pod in the change's design.md.
Scenario: Measurement is recorded
- WHEN The pull request is opened
- THEN The
design.mdstates the request count for one new pod and the method used
Existing Tool Considered
No alternatives check has run. No external tool or library covers this need. The change reuses existing project code: keep_state_record in src/devops_cli/server/service.py:158 persists the Service state across restarts, and the GitHub session's conditional If-None-Match read stays as the fallback. The change adds no new dependency and builds no replacement tool. The cost is the edit to src/devops_cli/github/metrics.py and its tests.
Key questions
- Where does the per-item label-time cache live so that a new pod keeps the reads?: In the Service state record that
keep_state_recordwrites, under a newitem_label_timeskey. The record already survives a restart. (best practice) [sources: src/devops_cli/server/service.py:158, src/devops_cli/roadmap/run.py:1106, openspec/changes/archive/2026-10-28-2474-service-state-survives-restart/design.md:15, src/devops_cli/github/metrics.py:481]- Chosen: Persist in the Service state record. The record already survives a restart and the Service writes it each round.
- Rejected: Write a separate shared file. It adds a second state path and a volume that the Service does not need.
- Rejected: Re-read every item on each new pod. That is the defect that spends the GitHub budget.
- How many items may the metrics row read label events for in one round?: At most 20 items per round. The row keeps the rest in the state record for later rounds. The cap holds the row near its pre-feat(telemetry): measure how long roadmap items wait in each state #3601 cost of about 222 to 305 requests an hour. (best practice) [sources: src/devops_cli/github/metrics.py:481, src/devops_cli/github/metrics.py:518]
- Chosen: Cap at 20 items per round. 20 items at the metrics schedule stays within the pre-feat(telemetry): measure how long roadmap items wait in each state #3601 hourly cost and leaves budget for other rows.
- Rejected: Cap at 100 items per round. A new pod would still spend a large share of the 2000-request budget in one round.
- Rejected: No cap. A new pod reads all open items and repeats the defect.
- What key and version identify a cache entry?: The key is the repository full name and the issue number. The version is the item's
updated_at. A match lets the row skip the label-event read. (best practice) [sources: src/devops_cli/github/metrics.py:481, src/devops_cli/github/metrics.py:518]- Chosen: Use
(repo, issue number)withupdated_at. The key finds the item andupdated_atchanges when the item changes. - Rejected: Use only
(repo, issue number). Labels can change without a new issue number, so the row would miss the change. - Rejected: Use a hash of the issue body.
updated_atalready changes on edits and needs no hash.
- Chosen: Use
- What happens when the state record write fails?: The metrics row logs one error and keeps the in-memory cache. The next round writes the record again. (best practice) [sources: src/devops_cli/server/service.py:158, openspec/changes/archive/2026-10-28-2474-service-state-survives-restart/design.md:15]
- Chosen: Log and continue. A write failure must not end the worker or restart the pod.
- Rejected: Fail the metrics round. An exception ends the worker and
/healthzrestarts the pod with no halt.
- What happens to cache entries for items that are no longer open?: The metrics row removes the entry at the end of the round when the open item list no longer holds the item. (best practice) [sources: src/devops_cli/github/metrics.py:524, src/devops_cli/github/metrics.py:525]
- Chosen: Prune at the end of the round. The state record stays small and holds only open items.
- Rejected: Keep the entry forever. The state record grows without a limit.
- Rejected: Prune only when the record is full. It adds a second limit and delays the removal.
- How does the change measure the requests for one new pod?: Run one new pod with the kept state record. Read the
devops_cli_github_requests_totalcounter with rowmetricsbefore and after one metrics round. State the difference indesign.md. (best practice) [sources: src/devops_cli/github/metrics.py]- Chosen: Use the existing
devops_cli_github_requests_totalcounter. The counter already labels each GitHub request by row. - Rejected: Add a new measurement counter. The existing counter gives the same number without new code.
- Chosen: Use the existing
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-07: none.
Tool: none found.
Activity
dan-petty commentedon Nov 5, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(telemetry)scope of the title gives the scope.The Service exhausts its 2000-request budget and a rollout adds the cost, but the Service still runs and the cause is known.Every rollout burns the full GitHub budget for the metrics row, which can starve other Service work.It needs a persisted cache, a bounded read per round, two tests, and a live soak check.Both address telemetry behaviour that changes across pods, but #3495 fixes counter accuracy in Prometheus while the candidate reduces GitHub API reads on pod start.devops-cli-service commentedon Nov 6, 2026
Status set to Ready at 27c7019 (see proposed design in issue body).
Moved to new items: #3794.
devops-cli-service commentedon Nov 7, 2026
Alternatives check: none
Reason: The searches returned no results (the search provider answered none of the queries), and the issue itself asks for no new tool: the fix persists the per-process item label-time cache in the Service's existing state record (
keep_state_record) and caps the item reads per round, keeping the GitHub session's conditionalIf-None-Matchread as the fallback. No external tool or library covers a persisted, per-round-bounded item label-event cache, and the project ADRs select no candidate for it (ADR 0006 already fixes the session transport as gidgethub).Tool: none found
Lacks:
src/devops_cli/github/metrics.py) and the state record written bykeep_state_recordSearches run:
Checked on 2026-11-07. A person decides what this means for the item. The check changes no label and closes no issue.
70 remaining items
docs(openspec): archive the change (#3634)
dan-petty commentedon Nov 19, 2026
New evidence from the Service config review of 2026-11-19: the GitHub request budget holds follow the Service starts.
devops_cli_service_budget_spent_requests >= 3950) began within 1 h after a Service pod start. Those hours cover only 46% of the time. There were 122 Service pod starts in 7 d and 12 in the last 24 h.sum(increase(devops_cli_github_requests_total{job="roadmap-service",status!="304"}[20m])).metricsrow rose by about 555 in 40 min.refinerow also rose after a start: about 796 counted requests in 40 min, against about 500 at other times. No issue covers that yet.Plan: after #6326 is live, measure the counted requests by row in the 40 min after the next Service starts. File a new issue only for a row that still spikes, for example
refine. A persisted ETag store is not needed for this.fix(telemetry): Add the record of the item label times (#3634)
fix(telemetry): Key the label times by updated_at and cap the reads (#…
fix(telemetry): Measure the requests of one new pod (#3634)
fix(telemetry): Keep the record in the state directory of the row (#3634
fix(telemetry): Name the record file in the cluster document (#3634)
fix(telemetry): State the live level of the metrics row (#3634)
fix(telemetry): read the oldest label-time entry first (#3634)
docs(openspec): archive the change (#3634)
devops-cli-service commentedon Nov 19, 2026
Released in v0.179.5: https://github.com/dan-petty/devops-cli/releases/tag/v0.179.5
devops-cli-service commentedon Nov 19, 2026
Live since 2026-11-19 11:42 UTC