Repository navigation
Description
Update 2026-11-26 (infra move): the Files list now names the product dashboard.
Problem or Motivation
No series holds the count that GitHub keeps of the devops-cli API use. devops_cli_github_requests_total counts attempts on the client side: a gh command counts as one request with status 'none', a paginated read counts as 1 (#4737), and counter streams lose counts between the collector and Prometheus (#4684). Each GitHub answer carries the headers x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-used, x-ratelimit-reset and x-ratelimit-resource. devops-cli already reads them, from gh output (src/devops_cli/github/rate_limiter.py:598-616) and from the session (src/devops_cli/github/session_transport.py:225), into update_quota (rate_limiter.py:1179), but sends no metric of them. All pods of one App installation share one budget (ADR 0021).
Owner decision of 2026-11-11: GitHub's own count comes from gauges of these headers, with no new pod and no second copy of the Service App key.
Proposed Solution & Architectural Design
In update_quota, where both header paths land, set four gauges with the label resource (core, graphql, search, code_search and the other values that GitHub sends):
devops_cli_github_rate_limit_limitdevops_cli_github_rate_limit_remainingdevops_cli_github_rate_limit_useddevops_cli_github_rate_limit_reset_seconds(the Unix time of the window reset)
A gauge keeps the last value, so it has no false reset. The value is the count of GitHub for the identity at the time of the answer. An answer with no rate-limit header changes no gauge.
Add one panel to the GitHub row of devops-cli.json: used and limit by resource, as GitHub reports them, beside the counted requests of #4707. List the gauges in docs/TELEMETRY.md.
Scope: queries, panel types, units, legends and defaults only. Keep the default Grafana colors. The project design study owns colors and type.
Target Subsystem
SDLC, Git & PR Governance (GitHub client and its telemetry).
Existing Tool Considered
githubexporter/github-exporter v2.4.1 in rate-limit-only mode reads GET /rate_limit. The owner refused it on 2026-11-11: it needs a new pod with a second copy of the write-capable Service App key, and it cannot see the user token of a workstation. GET /rate_limit also counts against the secondary limit, while the headers come with each answer at no cost. Cost to build: about 60,000 tokens and 1 h; about 2,000 tokens a month to keep; about 10,000 tokens to fix.
Acceptance Criteria
- A test: a session answer with
x-ratelimit-limit5000,x-ratelimit-remaining4958,x-ratelimit-used42,x-ratelimit-reset1767225600 andx-ratelimit-resourcecore sets the four gauges of resource core to these values. - A test: gh output with the same headers sets the same gauges.
- A test: an answer with no rate-limit header changes no gauge.
docs/TELEMETRY.mdlists the four gauges.- A harness case for the new panel passes, and the dashboard tests pass.
- Live, for job roadmap-service over 1 h: used plus remaining equals limit for resource core at each sample.
Files
src/devops_cli/github/rate_limiter.pysrc/devops_cli/telemetry/instruments.pyk8s/devops/dashboards/devops-cli.jsondocs/TELEMETRY.mdtests/github/test_github_rate_limiter.pytests/telemetry/test_telemetry_instruments.pytests/fixtures/dashboard_queries/devops-cli.yaml
Dependencies
#4707 (the same row of devops-cli.json).
Related
#4563 (shares the GitHub budget in Valkey).
Source: #4675
Alternatives check of 2026-11-23: partly.
Tool: theodore86/github-rate-limits-exporter (https://github.com/theodore86/github-rate-limits-exporter), MIT, last activity 2026-11-22, maintained.
Reason: The searches found only GitHub rate-limit exporters, which do expose limit, remaining, used and reset per resource as Prometheus metrics, but only by polling GET /rate_limit from their own pod and token, not from the response headers in update_quota, so they cover the metric content and not the in-process path the issue requires.
Covers:
- Limit, remaining, used and reset per API resource
- A resource label with core, graphql, search, code_search
- Prometheus scrape endpoint ready to deploy
Lacks:
- No gauges emitted inside update_quota
- Polls GET /rate_limit with its own token from a new pod
- Needs a second copy of the write-capable App key
- Cannot see a workstation's user token
- No project dashboard panel or telemetry docs
Proposed design
Problem statement
No series holds the rate-limit count that GitHub keeps for the devops-cli identity. devops_cli_github_requests_total counts client attempts, and a counter stream can lose counts. The rate limiter already reads the x-ratelimit-* headers into update_quota, but it sends no metric of them. This change sends four gauges by resource, adds one dashboard panel, and lists the gauges in the telemetry document.
Acceptance criteria
Requirement: Session rate-limit gauges
The GitHub session SHALL set the four rate-limit gauges from the x-ratelimit-* headers of an answer, with the label resource.
Scenario: A session answer holds every rate-limit header
- WHEN an answer carries
x-ratelimit-limit5000,x-ratelimit-remaining4958,x-ratelimit-used42,x-ratelimit-reset1767225600 andx-ratelimit-resourcecore - THEN the four gauges of resource core hold 5000, 4958, 42 and 1767225600
Requirement: gh command rate-limit gauges
run_gh SHALL set the four gauges from the x-ratelimit-* headers that gh prints.
Scenario: gh output holds every rate-limit header
- WHEN gh output holds the same five header lines
- THEN the four gauges of resource core hold 5000, 4958, 42 and 1767225600
Requirement: Partial header answer
An answer SHALL set only the gauges of the rate-limit values that it holds.
Scenario: An answer holds no used and no reset header
- WHEN an answer holds
x-ratelimit-remaining4900 andx-ratelimit-limit5000, and no used and no reset header - THEN the remaining and limit gauges hold 4900 and 5000, and the used and reset gauges of that resource keep their last value
Requirement: Headerless answer
An answer with no rate-limit header SHALL change no rate-limit gauge.
Scenario: An answer holds no rate-limit header
- WHEN an answer carries no
x-ratelimit-*header - THEN the four gauges of the resource keep their last values
Requirement: Rate-limit refresh
The refresh read of GET /rate_limit SHALL set the four gauges of each resource in its body.
Scenario: A refresh body holds a graphql window
- WHEN a
GET /rate_limitbody holds graphql with limit 5000, used 66, remaining 4934 and a reset time - THEN the four gauges of resource graphql hold 5000, 66, 4934 and the reset time
Requirement: Declared gauge instruments
Each of the four gauges MUST be a declared instrument of the kind gauge, with the unit 1 or s and the label resource only.
Scenario: The instruments module is read
- WHEN
uv run pytest tests/telemetry/test_telemetry_instruments.pyruns - THEN the test passes for the four declared gauges, their units, the
resourcelabel only, and no_totalname
Requirement: GitHub API row panel
The GitHub API row of devops-cli.json SHALL hold one timeseries panel that shows the used and the limit of each resource with last_over_time on the two gauges.
Scenario: The dashboard tests read the row
- WHEN
uv run pytest tests/prometheus/test_dashboard_queries.py tests/telemetry/test_telemetry_instruments.pyruns - THEN the dashboard row test and the harness case for the new panel pass
Requirement: Telemetry gauge rows
docs/TELEMETRY.md SHALL list the four gauges in its metric table.
Scenario: The instrument test reads the document
- WHEN
uv run pytest tests/telemetry/test_telemetry_instruments.pyruns - THEN the test passes for each of the four gauge rows
Requirement: Pending a person after the merge
After the merge, a person SHALL verify over 1 h that used plus remaining equals limit for resource core for job roadmap-service.
Scenario: Live sample of the core resource
- WHEN a person reads the gauges for job roadmap-service over 1 h
- THEN used plus remaining equals limit for resource core at each sample
Existing Tool Considered
The alternatives check in the issue body records verdict partly for theodore86/github-rate-limits-exporter (MIT, maintained). That block lists what the tool covers and lacks. The proposal closes the gap it names: it emits the four gauges in update_quota from the x-ratelimit-* headers of each answer and from the GET /rate_limit refresh. It therefore needs no new pod, no second App key, and it sees the user token of a workstation. It also adds the dashboard panel and the telemetry rows. Cost to build the gauges in update_quota instead: about 60,000 tokens and 1 h to build, about 2,000 tokens a month to keep, and about 10,000 tokens to fix.
Key questions
- Does GitHub's own count come from gauges of the response headers, or from a separate exporter?: It comes from gauges of the
x-ratelimit-*headers inupdate_quota, with no new pod and no second App key. The owner decided this on 2026-11-11. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, src/devops_cli/github/rate_limiter.py]- Chosen: gauges of the response headers. Each answer carries the headers at no cost, and the rate limiter already reads them into
update_quota. - Rejected: separate exporter pod. It needs a new pod and a second copy of the write-capable App key, it cannot see a workstation token, and its polls can count against the secondary limit.
- Chosen: gauges of the response headers. Each answer carries the headers at no cost, and the rate limiter already reads them into
- Where does the code set the four gauges?: In
update_quota, which the session header path, the gh header path and theGET /rate_limitrefresh already call. The refresh passes each resource through it, so one emit there covers all three paths. (best practice) [sources: src/devops_cli/github/rate_limiter.py, src/devops_cli/github/session_transport.py]- Chosen: one emit inside
update_quota. All three paths land there, so one place sets the gauges and the refresh read sets them too. - Rejected: emit at each caller. Three copies drift apart, and a caller that forgets one sends no gauge.
- Chosen: one emit inside
- What names, kinds, units and labels do the four gauges have?:
devops_cli_github_rate_limit_limit,devops_cli_github_rate_limit_remaininganddevops_cli_github_rate_limit_usedare gauges of unit1.devops_cli_github_rate_limit_reset_secondsis a gauge of unitsthat holds the Unix time of the window reset. Each carries the labelresourceonly. (best practice) [sources: src/devops_cli/telemetry/instruments.py, docs/TELEMETRY.md, tests/telemetry/test_telemetry_instruments.py]- Chosen: four gauges with the label
resourceonly. The budget is one per identity, so a repository or row label adds series and states nothing new. - Rejected: counters of each answer. GitHub's count goes down as well as up, so a counter shows a false reset at each window.
- Rejected: gauges with
resource,repoandrow. The headers describe the budget of the identity, not of one repository or row, and each extra label multiplies the series.
- Chosen: four gauges with the label
- Which file holds the devops-cli dashboard?:
k8s/devops/dashboards/devops-cli.json. [sources: k8s/devops/dashboards/devops-cli.json, tests/telemetry/test_telemetry_instruments.py, tests/prometheus/test_dashboard_queries.py] - Which panel does the dashboard gain, and does it change an existing test?: One timeseries panel,
GitHub rate limit: used and limit by resource, joins the GitHub API row. It reads the gauges withlast_over_timeover$__range. The row test asserts the exact set of panels, so the change updates that test with the new panel. (best practice) [sources: tests/telemetry/test_telemetry_instruments.py, k8s/devops/dashboards/devops-cli.json, docs/TELEMETRY.md]- Chosen: one panel in the GitHub API row, with the row test updated. The row holds the GitHub budget panels, so GitHub's used and limit sit beside the counted requests of fix(monitoring): make the GitHub and command panels readable #4707.
- Rejected: a new row of its own. A row costs vertical space and separates the gauge from the counted requests that it explains.
- Does this item still wait on fix(monitoring): make the GitHub and command panels readable #4707?: No. The GitHub API row of
devops-cli.jsonalready holds the five panels of fix(monitoring): make the GitHub and command panels readable #4707 at the refined commit, so the row and its test are in place. [sources: tests/telemetry/test_telemetry_instruments.py, tests/fixtures/dashboard_queries/devops-cli.yaml, openspec/specs/github-api-metrics/spec.md] - Which values must the session and gh header paths pass to
update_quota?: The session path must passusedfromx-ratelimit-usedand theresourcefromx-ratelimit-resource, in addition to remaining, limit and reset. The gh parser_process_header_metricsmust addx-ratelimit-resourceto its table, or the gh path cannot label the gauges by resource. (best practice) [sources: src/devops_cli/github/session_transport.py, src/devops_cli/github/rate_limiter.py]- Chosen: pass
usedandresourcein both paths. The acceptance tests use resource core and graphql, and the gauges need both values to carry the correct label and count. - Rejected: default every answer to resource core. GitHub sends graphql, search and code_search answers, so a core default labels those values with the wrong resource.
- Rejected: emit the gauges without the resource label. The issue requires the label
resource, and a dashboard cannot separate the budgets without it.
- Chosen: pass
- Does
docs/TELEMETRY.mdget the four rows from the generator or from a hand edit?:docs/TELEMETRY.mdis generated.src/devops_cli/docs/generator.pyreadsINSTRUMENTS, so the change declares the four instruments and regenerates the document. No hand edit of the table is needed. [sources: src/devops_cli/docs/generator.py, docs/TELEMETRY.md, src/devops_cli/telemetry/instruments.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
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.(github)scope of the title gives the scope.Observability improvement that aids operators but does not block a release or fix a defect.Gives operators visibility into GitHub's own rate-limit budget per resource, reducing blind spots in capacity planning.Four gauges, one panel, docs update, and tests in well-scoped files; the body estimates about one hour.Both add GitHub API metrics to the same dashboard and instruments.py, but #814 adds client-side request counters while this adds server-side rate-limit gauges from response headers.dan-petty commentedon Nov 12, 2026
Addition (owner direction of 2026-11-12, ADR 0026 of #5223). The title stays.
ADR 0026 moves the issue and pull request commands of
devops ghanddevops prto gh's GraphQL commands. gh prints no rate-limit header for these commands, so the header path of this item does not see them.devops_cli_github_graphql_points_totalcounts points only for answers that hold arateLimitfield (rate_limiter.py:546-559). The rate limiter already readsGET /rate_limitwhen its stored quota is old (_refresh_from_github). The body of that answer holdslimit,used,remainingandresetfor each resource.Added scope
GET /rate_limitsets the four gauges of each resource in its body, throughupdate_quota.docs/TELEMETRY.mdgives the query of the trigger of ADR 0026: one hour above 2,500 ondevops_cli_github_rate_limit_used{resource="graphql"}for one job.Acceptance Criteria (additions)
GET /rate_limitbody with graphql used 66 and remaining 4,934 sets the gauges of resource graphql to these values.Dependencies
No change. #5223 does not wait for this item. Until it merges, the trigger of ADR 0026 uses the hourly sum of GraphQL requests and reported points.
devops-cli-service commentedon Nov 14, 2026
Alternatives check: partly
Reason: The searches found standalone Prometheus exporters for GitHub's rate-limit budget:
theodore86/github-rate-limits-exporter(and the issue's own refused candidate,githubexporter/github-exporter) expose limit, remaining, used and reset per API resource as Prometheus metrics, which is the metric set the issue wants. Neither reads thex-ratelimit-*headers of each answer inside devops-cli: both pollGET /rate_limitwith their own token from a separate exporter, so they need a new pod and a second token copy and cannot see a workstation's user token — hence they cover only part of the need.Tool: theodore86/github-rate-limits-exporter (https://github.com/theodore86/github-rate-limits-exporter)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 15, 2026
Status set to Ready at e5dfddb (see proposed design in issue body).
8 remaining items
devops-cli-service commentedon Nov 26, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
chore(main): release 0.238.0 (#7615)
devops-cli-service commentedon Nov 28, 2026
Released in v0.238.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.238.0
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 18:38 UTC