Skip to content

fix(telemetry): read repository traffic as the GitHub App - #4932

Merged
dan-petty merged 12 commits into
mainfrom
fix/4757-emit-traffic-per-repository-on-a
Nov 12, 2026
Merged

dan-petty merged 12 commits into
mainfrom
fix/4757-emit-traffic-per-repository-on-a

Conversation

@devops-cli-service

@devops-cli-service devops-cli-service Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

The traffic row of the project dashboard has no sample since 2026-10-30. The Service acts as the GitHub App, and its installation token asks for no Administration read, so get_repository_traffic_metrics returns no traffic and the four panels stay empty. GitHub keeps traffic for 14 days only, so each day without a read loses data. This change delivers #4757: it gives the token the permission, removes the App skip, and names the missing permission when GitHub refuses a traffic endpoint.

The App setup steps of k8s/README.md name Administration read, because GitHub refuses every token with HTTP 422 when the installation does not grant it. The descriptions of the four traffic panels say that the roadmap Service and devops gh metrics --emit-telemetry send the traffic numbers.

ADR 0015 now states the rule that the code follows: each token asks for one shared set, a feature that needs one more permission adds it to that set with an amendment line, and a person confirms the grant on the installation page before such a change merges. It also records what Administration read can read.

Closes #4757

Change: openspec/changes/archive/2026-11-12-4757-emit-traffic-per-repository-on-a/

@devops-cli-service devops-cli-service Bot added type/docs Type docs: a change to the documents scope/openspec OpenSpec changes, specs and their checks verdict/fix-plan Verdict Needs fix of a plan: an open finding keeps the plan in draft until a fix labels Nov 12, 2026
@devops-cli-service

Copy link
Copy Markdown
Contributor Author

The stage_ready row leaves pull request #4932 a draft. It holds the label plan/needs-fix, because the model review of its plan found an open finding. Fix the plan, or remove the label when the finding is no defect.

@dan-petty
dan-petty force-pushed the fix/4757-emit-traffic-per-repository-on-a branch from a644e3e to 69cfef8 Compare November 12, 2026 10:18
@dan-petty dan-petty changed the title docs(openspec): plan #4757 Read repository traffic as the GitHub App fix(telemetry): read repository traffic as the GitHub App Nov 12, 2026
@dan-petty dan-petty added scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger type/bug Type bug: the code does not do what it must and removed type/docs Type docs: a change to the documents scope/openspec OpenSpec changes, specs and their checks verdict/fix-plan Verdict Needs fix of a plan: an open finding keeps the plan in draft until a fix labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main at bd9732e88 (before the archive commit):

6 failed on base (6 failed and 76 passed in tests/github/test_github_app_identity.py, tests/github/test_github_metrics.py, tests/roadmap/test_roadmap_run_metrics.py; 0 errored).

The six tests that fail on the base and pass on the head:

  • tests/roadmap/test_roadmap_run_metrics.py::test_the_metrics_job_of_the_app_reads_the_traffic_of_the_repository[read]
  • tests/roadmap/test_roadmap_run_metrics.py::test_the_metrics_job_of_the_app_reads_the_traffic_of_the_repository[refused]
  • tests/github/test_github_app_identity.py::test_an_installation_without_a_requested_permission_fails_naming_the_permissions
  • tests/github/test_github_app_identity.py::test_the_token_request_asks_only_for_the_permissions_the_roadmap_jobs_use
  • tests/github/test_github_app_identity.py::test_a_runner_job_asks_for_a_token_that_names_one_repository
  • tests/github/test_github_metrics.py::test_a_path_that_the_token_cannot_read_is_asked_once

On the head, uv run pytest tests/github/test_github_app_identity.py tests/github/test_github_metrics.py tests/roadmap/test_roadmap_run_metrics.py gives 82 passed. uv run devops ci docs passes. ruff and mypy pass on the changed modules.

The same run also replayed the tests of the modules that import src/devops_cli/docs/generator.py: 3 of 312 failed on the base there, among them tests/commands/test_ci.py::test_a_sigterm_to_the_gate_stops_the_group_of_each_running_row_and_names_it. This change does not change those tests.

Plan finding

The stage review found spec_delta_wrong: the base requirement A refused permission names each permission that the token asks for listed seven permissions. The change now modifies that requirement, and also A report without traffic sends no traffic gauge, whose scenario under the App said that the row sends no traffic. The requirement The Service collects no repository traffic is renamed to The Service collects repository traffic.

@dan-petty

Copy link
Copy Markdown
Owner

Steps for a person

1. Before the merge: check the premise

The agent session could not run this probe: its permission check refused a script in the Service pod. The probe mints one installation token that asks for administration: read and reads the four traffic paths. It prints no token.

kubectl -n devops exec -i deploy/roadmap-service -c service -- /app/.venv/bin/python - <<'PY'
import json, urllib.request
from devops_cli.config.constants import CONST_URL_GITHUB_API_BASE
from devops_cli.github import app_installation as ai
ai.CONST_GITHUB_APP_TOKEN_PERMISSIONS = {"administration": "read", "metadata": "read"}
answer = ai._exchange(ai.configured_app())
print("granted:", sorted((answer.get("permissions") or {}).items()))
for path in ("views", "clones", "popular/referrers", "popular/paths"):
    request = urllib.request.Request(
        f"{CONST_URL_GITHUB_API_BASE}/repos/dan-petty/devops-cli/traffic/{path}",
        headers={"Authorization": f"token {answer['token']}", "Accept": "application/vnd.github+json"},
    )
    with urllib.request.urlopen(request, timeout=20) as reply:
        print(path, reply.status)
PY

Expected: granted: [('administration', 'read'), ('metadata', 'read')] and status 200 for each of the four paths.

If the mint fails with HTTP 422, the installation does not grant administration. Do not merge: each token of each job would then fail. Grant Administration (read) to the App installation first, or close this pull request with that reason.

2. After the rollout

No ConfigMap or Secret changes. The next metrics round of the Service reads the traffic.

  1. One hour after the rollout, run this query in Grafana Explore on Prometheus. It must give one series for each repository of service.repos:
    last_over_time(devops_cli_project_traffic_views{job='roadmap-service'}[1h])
  2. For the devops-cli repository, compare the value with count from uv run devops gh api repos/dan-petty/devops-cli/traffic/views --jq .count. The two must be equal, or differ only by the views between the two reads.
  3. Search the Service log for GitHub refused the traffic of. A line means that GitHub refused the traffic of that repository; the line names the missing permission.

@dan-petty
dan-petty force-pushed the fix/4757-emit-traffic-per-repository-on-a branch from 69cfef8 to 806261f Compare November 12, 2026 10:50
@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 10:57
@dan-petty
dan-petty self-requested a review as a code owner November 12, 2026 10:57
@dan-petty
dan-petty force-pushed the fix/4757-emit-traffic-per-repository-on-a branch from 806261f to e72f705 Compare November 12, 2026 11:37
@dan-petty

Copy link
Copy Markdown
Owner

Review findings and what I did (head e72f70563):

  1. Blocking, k8s/README.md: step 1 of the Roadmap service setup does not name Administration read. Confirmed: CONST_GITHUB_APP_TOKEN_PERMISSIONS asks for administration: read, and the step said that the App must grant at least the listed permissions. Fixed in 4ded44ba9: the list now ends with "Administration read", and a sentence says that the metrics row reads the repository traffic with it (fix(telemetry): emit traffic per repository on a schedule #4757). Proof: grep -c 'Administration read (#4757)' k8s/README.md prints 1.
  2. Major, k8s/monitoring/dashboards/project-metrics.json: the four traffic panels say that the roadmap Service sends no traffic. Confirmed on panels 16, 17, 19 and 20, and in the docstring of the dashboard test. Fixed in 3d7382862: each description now says "The roadmap Service and devops gh metrics --emit-telemetry send traffic numbers. A repository whose traffic GitHub refused has no traffic series." The test is now test_each_traffic_panel_names_the_senders_of_its_numbers. It requires both sentences and refuses "sends none". The queries did not change.

The OpenSpec design, proposal and tasks (group 4) name the two corrections, and the archive is again the last commit.

uv run devops ci fail-to-pass --base origin/main: 8 failed on base, 136 passed, 0 errored. The new failure on base is tests.prometheus.test_k8s_monitoring_dashboards::test_each_traffic_panel_names_the_senders_of_its_numbers. uv run devops ci docs passes.

Owner step before the merge is the same: run the premise probe of the earlier comment, so that a token that asks for administration: read gets HTTP 200 from the four traffic paths.

devops-cli-service Bot and others added 10 commits November 12, 2026 12:52
The installation token asks for administration: read, so the metrics row reads
the four traffic endpoints. A refusal logs one warning that names the
permission.
The token now asks for administration: read, so a reply with administration: write grants no extra permission. The test grants pages: write, which the token does not ask for.
The consequence said that a feature that needs more permissions asks for a token with its own set, but workflows, repository_hooks and administration went into the shared set. It now states the shared-set rule, the HTTP 422 risk of each addition, the person check of the installation grant, and what Administration read can read. The gidgethub bullet names the full set.


The deltas name repository_hooks of #5017, the extra-grant scenario grants pages: write, the ADR task replaces the own-set rule, the design counts the cost, and the person step before the merge is the installation page check. Dependencies name #5017 and #4574.
@dan-petty

Copy link
Copy Markdown
Owner

Rebase and review fixes (head 6d95c775a)

The branch is now on origin/main at b734eb331. The archive is again the last commit.

Conflicts

Main merged #5045 (#5017), which added repository_hooks: read to the same permission set. Each resolution keeps the text of main and adds the change of this pull request:

No spec of this change moved to a nested capability, so the deltas stay where they were.

Review findings fixed in this round

  1. ADR 0015 kept the rule "A later feature that needs more permissions asks for a token with its own set". workflows, repository_hooks and administration went into the shared set, so the rule was false. The consequence now states the shared-set rule, the HTTP 422 risk of each addition, the person check of the installation grant, and what Administration read can read (branch protection, rulesets and rule suites, the Actions policy, runners, deploy keys, invitations; no secret and no variable). The gidgethub bullet now names the full set.
  2. The scenario "GitHub's reply grants one more permission" granted administration: write, which the request now names. The test and the scenario now grant pages: write, which is outside the set.
  3. The github-app-identity deltas did not name repository_hooks of fix(service): find why webhook deliveries get HTTP 403 #5017, so the token body scenario and the HTTP 422 scenario would be false after the merge. Both now name the nine permissions.
  4. The plan did not count the cost. The design now counts about 129 requests an hour (7 repositories, 4 reads, 13-minute rounds), about 3.2 % of the Service budget of 4,000.
  5. Feasibility now cites fix(roadmap): the App token can push a workflow file #3519 (the owner saw read and write on all repository permissions on 2026-11-04) and the Prometheus count of 7 repositories. Dependencies name fix(service): find why webhook deliveries get HTTP 403 #5017 and feat(roadmap): run the reconcile sweep on a cluster schedule #4574 in place of three merged pull requests.
  6. The design records that the paths and referrers gauges put the top paths and referrers of the private repositories of service.repos into the cluster Prometheus as label values. No remote_write sends them out of the cluster.

Findings that the earlier rounds fixed: the HTTP 422 requirement and test, "A report without traffic sends no traffic gauge", the rename of the traffic requirement, docs/TELEMETRY.md, the four panel descriptions, k8s/README.md, and the refusal scenario.

Verification

  • uv run pytest tests/github/test_github_app_identity.py tests/github/test_github_metrics.py tests/roadmap/test_roadmap_run_metrics.py tests/prometheus/test_k8s_monitoring_dashboards.py tests/docs/test_docs.py::test_doc_generator_telemetry_docs: 99 passed.
  • uv run mypy on the three changed source files: no issues.
  • uv run devops ci --check --only lint,format,docs,openspec: all pass.
  • GitHub checks on 6d95c775a: all pass, among them Tests & Coverage (4 shards), Changed-Test Independence, Fail-to-Pass Check, Static Analysis, CodeQL and the Service, MCP Server and Runner images. Dependency Freshness, Plan Check, Test Job Duration and Tests on Main were skipped.

Findings that stay open

Owner step before the merge

Open the installation page of App devops-cli-service and confirm that Administration is granted (read, or read and write) and that no permission request waits. If it is not granted, do not merge: GitHub refuses each token of each job with HTTP 422, and the Service and every cluster Job lose GitHub. This check replaces the kubectl exec probe of the earlier comment.

The pull request is not a draft. Make it a draft again, or merge it only after the step above and your "safe and vetted" call.

@dan-petty
dan-petty merged commit 7c42823 into main Nov 12, 2026
28 checks passed
@dan-petty
dan-petty deleted the fix/4757-emit-traffic-per-repository-on-a branch November 12, 2026 13:23
dan-petty pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.119.0](v0.118.0...v0.119.0)
(2026-11-12)


### Features

* **repos:** the claim sets In Progress
([#5111](#5111))
([06ef1c6](06ef1c6))
* **roadmap:** a fix-plan step repairs a plan PR with open findings
([#5104](#5104))
([ca5b16d](ca5b16d))
* **roadmap:** extend stage review rounds while open findings drop
([#5090](#5090))
([bacf713](bacf713))
* **roadmap:** re-anchor a stale citation that matches one line
([#5040](#5040))
([16356d8](16356d8))


### Bug Fixes

* **ci:** keep failed test IDs in the service image shard summary
([#5106](#5106))
([88589ef](88589ef))
* **github:** count each page of a paginated GitHub read
([#5070](#5070))
([908e24a](908e24a))
* **github:** keep the metrics permissions out of the runner Job token
([#5064](#5064))
([fb549ff](fb549ff))
* **github:** pace mutations through the clock seam
([#5063](#5063))
([2bd87bc](2bd87bc))
* **k8s:** delete the CoreDNS files that k3s never applies
([#5055](#5055))
([463f601](463f601))
* **monitoring:** tidy LLM stack windows, units and lines
([#5052](#5052))
([375d724](375d724))
* **roadmap:** a refused kept plan uses no stage gate return
([#4983](#4983))
([b8adbca](b8adbca))
* **roadmap:** count a command as removed only when MUST NOT governs it
([#4985](#4985))
([2e6f407](2e6f407))
* **roadmap:** cut prose after a cited stage command
([#4982](#4982))
([a172563](a172563))
* **roadmap:** name every module of a group with no named test
([#5089](#5089))
([27a0e79](27a0e79))
* **roadmap:** stage returns every open review finding to the planner
([#5067](#5067))
([21b116e](21b116e))
* **roadmap:** the alternatives check reads the tools in use
([#5062](#5062))
([8903233](8903233))
* **roadmap:** the constants gate reads 6_500 and no new value
([#5080](#5080))
([8a7b113](8a7b113))
* **roadmap:** the constants gate reads only a stated value
([#5042](#5042))
([cf4733e](cf4733e))
* **telemetry:** read repository traffic as the GitHub App
([#4932](#4932))
([7c42823](7c42823))
* **tests:** close the UDP, DNS and git gaps of the network floor
([#5101](#5101))
([047ee48](047ee48))
* **tests:** repair the bwrap contract suite and gate it
([#5110](#5110))
([9a0659d](9a0659d)),
closes [#4715](#4715)


### Performance Improvements

* **ci:** build the Service image once for its test shards
([#5079](#5079))
([dcf5bd5](dcf5bd5))
* **ci:** run only the required checks on the release PR
([#5057](#5057))
([8174071](8174071))
* **ci:** stop the cache export of pull request image builds
([#5113](#5113))
([ba30820](ba30820))
* **roadmap:** consolidate keeps its vectors in the shared tiers
([#5099](#5099))
([2a8bf1a](2a8bf1a))


### Code Refactoring

* **roadmap:** one Status writer for every job
([#5109](#5109))
([24cfedc](24cfedc))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(telemetry): emit traffic per repository on a schedule

1 participant