Repository navigation
Support repository-wide workflow metrics and job step durations - #868
uzairchhapra wants to merge 2 commits into
Conversation
itsmylife
left a comment
There was a problem hiding this comment.
Thanks a lot for the contribution, @uzairchhapra! Repository-wide runs and step durations fill a real gap. I tested this locally against grafana/github-datasource: blank Workflow, workflow ID, file name and branch filters all work, and step durations match the timestamps.
A few things before we can merge:
-
Reduce API calls for Workflow Job Steps. One query can make ~60 sequential REST calls with no caching, so a dashboard refreshing every minute would use most of a PAT's 5,000 requests/hour. Suggestions:
- Fetch only the runs you use: request one page with
per_page=50instead of paging through up to 1,000 runs and then truncating to 50. - Cache jobs for completed runs: once a run has
status=completed, its jobs and steps for that attempt don't change. Cache them in memory byrun_id+run_attemptand only callListWorkflowJobsfor new or in-progress runs. After the first load, a refresh costs 1–2 calls. - Conditional requests:
304 Not Modifiedresponses don't count against GitHub's rate limit. Use an ETag-aware HTTP cache in the REST client (e.g.gregjones/httpcache). - Bounded concurrency when fetching jobs (e.g.
errgroupwith a limit of ~5). It doesn't lower the call count, but it keeps wide ranges under the query timeout.
The first two matter most; the other two are nice to have.
- Fetch only the runs you use: request one page with
-
Handler pattern: the new handler calls
s.Datasource.clientdirectly. Please follow the existing pattern (Datasource.HandleWorkflowJobStepsQuery→GetWorkflowJobSteps(ctx, models.Client, …)) and addListWorkflowJobstomodels.Client. -
Tests: please add tests for
getWorkflowJobStepscovering truncation and the warning notice, job pagination, and error wrapping. -
Changeset: please mention that saved queries with a blank Workflow used to fail and now return every run in the repository.
-
Docs: the token permission tables in
configure.mddon't list Actions: Read, which both query types need. -
Rebase: the branch is one commit behind
main(2.11.0 release prep).
Optional nits:
- Validate the Workflow value. GitHub accepts
137535905was ID137535905, so typos silently match a workflow. Allowing only blank, digits, or*.yml/*.yamlwould catch that. - The Workflow field commits only on blur, so pressing Enter runs the previous value. Committing on Enter too would help.
Allow workflow runs across all workflows and expose job step durations. Refs grafana#326
b35e9be to
72675de
Compare
|
Thanks for testing this and for the feedback! I rebased onto Two production edge cases remain:
Could you take another look at the current changes and let me know whether you would prefer those two safeguards here or as a follow-up? |
Type of Change
Feature
What is this feature?
Leave Workflow blank in Workflow Runs to return repository-wide runs using GitHub's repository Actions endpoint. Existing workflow ID and file name filters still work. The new Workflow Job Steps query uses the same optional filters and exposes per-step duration for bottleneck dashboards.
Why is this needed?
Dashboards should be able to count run outcomes across a repository without enumerating workflows. The step query also provides the step-level durations requested in #326.
How to test
grafana, Repositorygithub-datasource, and the UTC range November 17, 2026, 00:00:00–23:59:59.conclusionand countidfor repository-level outcomes. Populate a workflow ID to narrow the results to one definition.workflow_name,job_name, andstep_nameto compare step durations.Verification
/api/ds/querypath against GitHub. The range above returned 16 runs across 8 workflows (12 successful, 4 skipped). The workflow ID filter returned a single workflow. The steps query returned 622 steps across 7 workflows; all 500 measured durations matched the difference between completion and start timestamps.Special notes for your reviewer
The time filter is based on run creation. To limit GitHub requests, step details are scoped to the latest attempt of the 50 most recent matching runs and show a warning on truncation. Workflow Runs is the intended source for repository-level counts. Self-hosted runner assignment latency is not inferred from workflow or step timestamps.
Refs #326, #508, and #173.