metrics cardinality for ghalistener (#3671)

Co-authored-by: Bassem Dghaidi <568794+Link-@users.noreply.github.com>
Co-authored-by: Nikola Jokic <jokicnikola07@gmail.com>
This commit is contained in:
Chris Johnston 2025-02-26 09:34:17 -05:00 committed by GitHub
parent 7ccc177b84
commit ddc872d3ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 56 additions and 68 deletions

View File

@ -3,7 +3,6 @@ package metrics
import ( import (
"context" "context"
"net/http" "net/http"
"strconv"
"time" "time"
"github.com/actions/actions-runner-controller/github/actions" "github.com/actions/actions-runner-controller/github/actions"
@ -19,11 +18,8 @@ const (
labelKeyOrganization = "organization" labelKeyOrganization = "organization"
labelKeyRepository = "repository" labelKeyRepository = "repository"
labelKeyJobName = "job_name" labelKeyJobName = "job_name"
labelKeyJobWorkflowRef = "job_workflow_ref"
labelKeyEventName = "event_name" labelKeyEventName = "event_name"
labelKeyJobResult = "job_result" labelKeyJobResult = "job_result"
labelKeyRunnerID = "runner_id"
labelKeyRunnerName = "runner_name"
) )
const githubScaleSetSubsystem = "gha" const githubScaleSetSubsystem = "gha"
@ -43,14 +39,13 @@ var (
labelKeyOrganization, labelKeyOrganization,
labelKeyEnterprise, labelKeyEnterprise,
labelKeyJobName, labelKeyJobName,
labelKeyJobWorkflowRef,
labelKeyEventName, labelKeyEventName,
} }
completedJobsTotalLabels = append(jobLabels, labelKeyJobResult, labelKeyRunnerID, labelKeyRunnerName) completedJobsTotalLabels = append(jobLabels, labelKeyJobResult)
jobExecutionDurationLabels = append(jobLabels, labelKeyJobResult, labelKeyRunnerID, labelKeyRunnerName) jobExecutionDurationLabels = append(jobLabels, labelKeyJobResult)
startedJobsTotalLabels = append(jobLabels, labelKeyRunnerID, labelKeyRunnerName) startedJobsTotalLabels = jobLabels
jobStartupDurationLabels = append(jobLabels, labelKeyRunnerID, labelKeyRunnerName) jobStartupDurationLabels = jobLabels
) )
var ( var (
@ -227,7 +222,6 @@ func (b *baseLabels) jobLabels(jobBase *actions.JobMessageBase) prometheus.Label
labelKeyOrganization: jobBase.OwnerName, labelKeyOrganization: jobBase.OwnerName,
labelKeyRepository: jobBase.RepositoryName, labelKeyRepository: jobBase.RepositoryName,
labelKeyJobName: jobBase.JobDisplayName, labelKeyJobName: jobBase.JobDisplayName,
labelKeyJobWorkflowRef: jobBase.JobWorkflowRef,
labelKeyEventName: jobBase.EventName, labelKeyEventName: jobBase.EventName,
} }
} }
@ -244,16 +238,12 @@ func (b *baseLabels) scaleSetLabels() prometheus.Labels {
func (b *baseLabels) completedJobLabels(msg *actions.JobCompleted) prometheus.Labels { func (b *baseLabels) completedJobLabels(msg *actions.JobCompleted) prometheus.Labels {
l := b.jobLabels(&msg.JobMessageBase) l := b.jobLabels(&msg.JobMessageBase)
l[labelKeyRunnerID] = strconv.Itoa(msg.RunnerId)
l[labelKeyJobResult] = msg.Result l[labelKeyJobResult] = msg.Result
l[labelKeyRunnerName] = msg.RunnerName
return l return l
} }
func (b *baseLabels) startedJobLabels(msg *actions.JobStarted) prometheus.Labels { func (b *baseLabels) startedJobLabels(msg *actions.JobStarted) prometheus.Labels {
l := b.jobLabels(&msg.JobMessageBase) l := b.jobLabels(&msg.JobMessageBase)
l[labelKeyRunnerID] = strconv.Itoa(msg.RunnerId)
l[labelKeyRunnerName] = msg.RunnerName
return l return l
} }

View File

@ -21,8 +21,7 @@ func init() {
) )
} }
var ( var runtimeBuckets []float64 = []float64{
runtimeBuckets []float64 = []float64{
0.01, 0.01,
0.05, 0.05,
0.1, 0.1,
@ -69,7 +68,6 @@ var (
3000, 3000,
3600, 3600,
} }
)
func metricLabels(extras ...string) []string { func metricLabels(extras ...string) []string {
return append(append([]string{}, commonLabels...), extras...) return append(append([]string{}, commonLabels...), extras...)