Repository navigation
Add an option to omit the branch label from the workflow metrics - #313
Open
danielheimburg wants to merge 1 commit into
Open
danielheimburg wants to merge 1 commit into
danielheimburg wants to merge 1 commit into
Conversation
Every branch adds its own series to the workflow metrics and they are never removed, so pull request and merge queue branches grow the series count without bound. --metrics.omit-branch-label (GITHUB_METRICS_OMIT_BRANCH) registers the five webhook metrics without the branch label. It is off by default. Signed-off-by: Daniel Heimburg <5831617+danielheimburg@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every series of the webhook metrics carries a
branchlabel, and the exporter keeps a series until it restarts. In an organization with many pull requests and a merge queue (gh-readonly-queue/main/pr-N-<sha>refs), each branch adds a new set of series, so the series count only grows. Dropping the label in Prometheus withlabeldropdoes not work, because series that differ only by branch then collide.This adds
--metrics.omit-branch-label(envGITHUB_METRICS_OMIT_BRANCH), off by default. When set,workflow_job_duration_seconds,workflow_job_duration_seconds_total,workflow_job_status_count,workflow_execution_time_secondsandworkflow_status_countare registered without thebranchlabel, and all branches of a workflow count towards the same series.Changes:
PrometheusObservernow owns the five metrics and builds them with or withoutbranch(NewPrometheusObserver). A second observer on the same registry reuses the registered metrics, so creating the server more than once (as the server tests do) keeps working.go test -race ./...andgolangci-lint run(v2.14) pass locally. The Helm chart is unchanged, its container args are fixed in the template.