From be1bfcb2217ff175fb75d295dc064dfe7ae88874 Mon Sep 17 00:00:00 2001 From: Sindunuraga Rikarno Putra Date: Tue, 14 Nov 2023 13:11:36 +0100 Subject: [PATCH] ACCDT-1238: Add `runner_name` label (#2) * add runner_name as extra label * check for existence of runner name * keep consistency of cardinality --- pkg/actionsmetrics/event_reader.go | 6 +++++- pkg/actionsmetrics/metrics.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/actionsmetrics/event_reader.go b/pkg/actionsmetrics/event_reader.go index 606891fe5e..a1b7e2f40e 100644 --- a/pkg/actionsmetrics/event_reader.go +++ b/pkg/actionsmetrics/event_reader.go @@ -137,7 +137,11 @@ func (reader *EventReader) ProcessWorkflowJobEvent(ctx context.Context, event in githubWorkflowJobQueueDurationSeconds.With(labels).Observe(parseResult.QueueTime.Seconds()) case "completed": - githubWorkflowJobsCompletedTotal.With(labels).Inc() + var rn string + if n := e.WorkflowJob.RunnerName; n != nil { + rn = *n + } + githubWorkflowJobsCompletedTotal.With(extraLabel("runner_name", rn, labels)).Inc() // job_conclusion -> (neutral, success, skipped, cancelled, timed_out, action_required, failure) githubWorkflowJobConclusionsTotal.With(extraLabel("job_conclusion", *e.WorkflowJob.Conclusion, labels)).Inc() diff --git a/pkg/actionsmetrics/metrics.go b/pkg/actionsmetrics/metrics.go index 972a6f9f5e..877b905b81 100644 --- a/pkg/actionsmetrics/metrics.go +++ b/pkg/actionsmetrics/metrics.go @@ -175,7 +175,7 @@ var ( Name: "github_workflow_jobs_completed_total", Help: "Total count of workflow jobs completed (events where job_status=completed)", }, - metricLabels(), + metricLabels("runner_name"), ) githubWorkflowJobFailuresTotal = prometheus.NewCounterVec( prometheus.CounterOpts{