Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit d959192

Browse files
christophermichaeljohnstonLink-nikola-jokic
authored andcommitted
metrics cardinality for ghalistener (actions#3671)
Co-authored-by: Bassem Dghaidi <568794+Link-@users.noreply.github.com> Co-authored-by: Nikola Jokic <jokicnikola07@gmail.com>
1 parent 9d4ed53 commit d959192

2 files changed

Lines changed: 56 additions & 68 deletions

File tree

cmd/ghalistener/metrics/metrics.go

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package metrics
33
import (
44
"context"
55
"net/http"
6-
"strconv"
76
"time"
87

98
"github.com/actions/actions-runner-controller/github/actions"
@@ -19,11 +18,8 @@ const (
1918
labelKeyOrganization = "organization"
2019
labelKeyRepository = "repository"
2120
labelKeyJobName = "job_name"
22-
labelKeyJobWorkflowRef = "job_workflow_ref"
2321
labelKeyEventName = "event_name"
2422
labelKeyJobResult = "job_result"
25-
labelKeyRunnerID = "runner_id"
26-
labelKeyRunnerName = "runner_name"
2723
)
2824

2925
const githubScaleSetSubsystem = "gha"
@@ -43,14 +39,13 @@ var (
4339
labelKeyOrganization,
4440
labelKeyEnterprise,
4541
labelKeyJobName,
46-
labelKeyJobWorkflowRef,
4742
labelKeyEventName,
4843
}
4944

50-
completedJobsTotalLabels = append(jobLabels, labelKeyJobResult, labelKeyRunnerID, labelKeyRunnerName)
51-
jobExecutionDurationLabels = append(jobLabels, labelKeyJobResult, labelKeyRunnerID, labelKeyRunnerName)
52-
startedJobsTotalLabels = append(jobLabels, labelKeyRunnerID, labelKeyRunnerName)
53-
jobStartupDurationLabels = append(jobLabels, labelKeyRunnerID, labelKeyRunnerName)
45+
completedJobsTotalLabels = append(jobLabels, labelKeyJobResult)
46+
jobExecutionDurationLabels = append(jobLabels, labelKeyJobResult)
47+
startedJobsTotalLabels = jobLabels
48+
jobStartupDurationLabels = jobLabels
5449
)
5550

5651
var (
@@ -223,12 +218,11 @@ type baseLabels struct {
223218

224219
func (b *baseLabels) jobLabels(jobBase *actions.JobMessageBase) prometheus.Labels {
225220
return prometheus.Labels{
226-
labelKeyEnterprise: b.enterprise,
227-
labelKeyOrganization: jobBase.OwnerName,
228-
labelKeyRepository: jobBase.RepositoryName,
229-
labelKeyJobName: jobBase.JobDisplayName,
230-
labelKeyJobWorkflowRef: jobBase.JobWorkflowRef,
231-
labelKeyEventName: jobBase.EventName,
221+
labelKeyEnterprise: b.enterprise,
222+
labelKeyOrganization: jobBase.OwnerName,
223+
labelKeyRepository: jobBase.RepositoryName,
224+
labelKeyJobName: jobBase.JobDisplayName,
225+
labelKeyEventName: jobBase.EventName,
232226
}
233227
}
234228

@@ -244,16 +238,12 @@ func (b *baseLabels) scaleSetLabels() prometheus.Labels {
244238

245239
func (b *baseLabels) completedJobLabels(msg *actions.JobCompleted) prometheus.Labels {
246240
l := b.jobLabels(&msg.JobMessageBase)
247-
l[labelKeyRunnerID] = strconv.Itoa(msg.RunnerId)
248241
l[labelKeyJobResult] = msg.Result
249-
l[labelKeyRunnerName] = msg.RunnerName
250242
return l
251243
}
252244

253245
func (b *baseLabels) startedJobLabels(msg *actions.JobStarted) prometheus.Labels {
254246
l := b.jobLabels(&msg.JobMessageBase)
255-
l[labelKeyRunnerID] = strconv.Itoa(msg.RunnerId)
256-
l[labelKeyRunnerName] = msg.RunnerName
257247
return l
258248
}
259249

pkg/actionsmetrics/metrics.go

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,55 +21,53 @@ func init() {
2121
)
2222
}
2323

24-
var (
25-
runtimeBuckets []float64 = []float64{
26-
0.01,
27-
0.05,
28-
0.1,
29-
0.5,
30-
1,
31-
2,
32-
3,
33-
4,
34-
5,
35-
6,
36-
7,
37-
8,
38-
9,
39-
10,
40-
12,
41-
15,
42-
18,
43-
20,
44-
25,
45-
30,
46-
40,
47-
50,
48-
60,
49-
70,
50-
80,
51-
90,
52-
100,
53-
110,
54-
120,
55-
150,
56-
180,
57-
210,
58-
240,
59-
300,
60-
360,
61-
420,
62-
480,
63-
540,
64-
600,
65-
900,
66-
1200,
67-
1800,
68-
2400,
69-
3000,
70-
3600,
71-
}
72-
)
24+
var runtimeBuckets []float64 = []float64{
25+
0.01,
26+
0.05,
27+
0.1,
28+
0.5,
29+
1,
30+
2,
31+
3,
32+
4,
33+
5,
34+
6,
35+
7,
36+
8,
37+
9,
38+
10,
39+
12,
40+
15,
41+
18,
42+
20,
43+
25,
44+
30,
45+
40,
46+
50,
47+
60,
48+
70,
49+
80,
50+
90,
51+
100,
52+
110,
53+
120,
54+
150,
55+
180,
56+
210,
57+
240,
58+
300,
59+
360,
60+
420,
61+
480,
62+
540,
63+
600,
64+
900,
65+
1200,
66+
1800,
67+
2400,
68+
3000,
69+
3600,
70+
}
7371

7472
func metricLabels(extras ...string) []string {
7573
return append(append([]string{}, commonLabels...), extras...)

0 commit comments

Comments
 (0)