Make the listenerMetrics example match the listener defaults - #4633
Make the listenerMetrics example match the listener defaults#4633KR-Ravindra wants to merge 1 commit into
Conversation
The commented listenerMetrics block in the gha-runner-scale-set charts is described as the default configuration, but it adds job_workflow_ref, job_workflow_name and job_workflow_target to the counters and histograms while defaultMetrics in cmd/ghalistener/metrics has none of them. Uncommenting the block to customise buckets therefore turned on per-ref labels on 45-bucket histograms and exploded series cardinality. Drop the three labels from the example so it equals defaultMetrics, document them as optional labels together with their cardinality cost, and add a test that decodes the example from both values files and compares it with defaultMetrics.
KR-Ravindra
left a comment
There was a problem hiding this comment.
Round 1 self-review.
- Checked
cmd/ghalistener/metrics/metrics.godefaultMetricson master: counters and histograms carryenterprise,organization,repository,job_name,event_name(+job_result) only, nojob_workflow_*, so the example in both values files was a superset of the defaults as described. - Ran
go test ./cmd/ghalistener/metrics/ -run TestChartValuesMetricsExampleMatchesDefaultson this branch (pass) and again with the two values files replaced by their master versions (fails withextra elements in list B: job_workflow_ref, job_workflow_name, job_workflow_targetfor all four metrics), so the test guards the drift it is meant to. - The uncommenting helper keys on the exact
# listenerMetrics:/# metrics:line and stops at the first line without the comment prefix, which matches the block layout in both files.
Default render is unchanged since the block stays commented out. Workflows need maintainer approval to run here; marking ready.
There was a problem hiding this comment.
🟢 Approval recommended
The changes are documentation/values-only plus a targeted regression test, with no runtime behavior changes and clear verification of example/default consistency.
Pull request overview
Aligns the Helm chart listenerMetrics commented examples with the listener’s built-in defaultMetrics to prevent users from unintentionally enabling high-cardinality workflow-ref labels when they only meant to adjust histogram buckets. Adds a regression test to ensure the examples cannot drift from defaultMetrics again.
Changes:
- Update both chart
values.yamlfiles so the commentedlistenerMetrics/listener.metricsexample label sets matchdefaultMetrics(removesjob_workflow_*from the example). - Rewrite the surrounding comment to clarify the example matches defaults and to document the cardinality impact of opting into
job_workflow_ref/job_workflow_target. - Add
cmd/ghalistener/metrics/chart_values_test.goto parse/uncomment the example blocks and assert metric names/labels/buckets matchdefaultMetrics.
File summaries
| File | Description |
|---|---|
| cmd/ghalistener/metrics/chart_values_test.go | Adds a Go unit test to ensure chart metric examples stay identical to defaultMetrics. |
| charts/gha-runner-scale-set/values.yaml | Makes the commented listenerMetrics example match listener defaults and improves cardinality guidance. |
| charts/gha-runner-scale-set-experimental/values.yaml | Same alignment and comment updates for the experimental chart’s nested listener.metrics example. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Problem
charts/gha-runner-scale-set/values.yaml(and thelistener.metricsblock incharts/gha-runner-scale-set-experimental/values.yaml) ship a commented-outlistenerMetricsexample introduced as the defaults ("Default buckets are provided here for documentation purposes") and tell users to uncomment it when they want custom histogram buckets.The example is not the default configuration. It adds
job_workflow_ref,job_workflow_nameandjob_workflow_targetto both counters and both histograms, while the listener's built-indefaultMetricshas none of them. Anyone who uncomments the block to tune buckets silently starts exporting per-ref/per-PR labels on histograms with 45 buckets, which multiplies the series count on busy repositories by orders of magnitude. Nothing in the file mentions the cardinality cost of those labels.Root cause
cmd/ghalistener/metrics/metrics.go:162-281(defaultMetrics): counters and histograms carry onlyenterprise,organization,repository,job_name,event_name(+job_result).charts/gha-runner-scale-set/values.yaml:160,:170-172,:194,:252-254andcharts/gha-runner-scale-set-experimental/values.yaml:327-328,:335,:344-346,:368,:426-428: the example lists the threejob_workflow_*labels on top of the defaults.job_workflow_refwas dropped from the defaults in #3671 because of cardinality (#3670, #3153) and re-added in #4054 as an opt-in label plus this example; #4240 then addedjob_workflow_name/job_workflow_targetto the example only. The example drifted into a superset of the defaults while the surrounding comment kept calling it the defaults.Fix
Documentation/values-only change; no template or Go behaviour changes.
job_workflow_*labels from the example in both charts so it matchesdefaultMetricsexactly. Uncommenting the block (for example to change buckets) no longer changes the exported label set.job_workflow_ref,job_workflow_nameandjob_workflow_targetas optional labels, and explain that the two ref-based labels create a new series per branch/pull request per job, multiplied by the bucket count on histograms.cmd/ghalistener/metrics/chart_values_test.go: uncomments the example block from both values files and asserts that the metric names, labels and buckets equaldefaultMetrics, so the example cannot drift again without the test failing.How tested
Before (test added, values unchanged):
After:
Also run:
go test ./cmd/ghalistener/metrics/andgo test ./charts/gha-runner-scale-set/tests/: passgo vet ./cmd/ghalistener/metrics/,gofmt -l: cleanhelm unittest charts/gha-runner-scale-set-experimental: 176 passedhelm lintandhelm templatewith default values for both charts: rendered output is byte-identical before and after (the block is commented out, so the default render is unchanged)helm template -f <uncommented example>on the main chart: the renderedlistenerMetricsnow carries the default label set onlyLinks
This change was prepared with an AI agent operated by KR-Ravindra, who reviewed and tested it.