@@ -62,6 +62,7 @@ func (m *MetricsCollectorGithubWorkflows) Setup(collector *collector.Collector)
62
62
[]string {
63
63
"org" ,
64
64
"repo" ,
65
+ "workflowID" ,
65
66
"workflow" ,
66
67
"state" ,
67
68
"path" ,
@@ -79,10 +80,13 @@ func (m *MetricsCollectorGithubWorkflows) Setup(collector *collector.Collector)
79
80
[]string {
80
81
"org" ,
81
82
"repo" ,
83
+ "workflowID" ,
82
84
"workflow" ,
83
85
"event" ,
84
86
"branch" ,
85
87
"conclusion" ,
88
+ "actorLogin" ,
89
+ "actorType" ,
86
90
},
87
91
)
88
92
m .Collector .RegisterMetricList ("workflowLatestRun" , m .prometheus .workflowLatestRun , true )
@@ -95,10 +99,13 @@ func (m *MetricsCollectorGithubWorkflows) Setup(collector *collector.Collector)
95
99
[]string {
96
100
"org" ,
97
101
"repo" ,
102
+ "workflowID" ,
98
103
"workflow" ,
99
104
"event" ,
100
105
"branch" ,
101
106
"conclusion" ,
107
+ "actorLogin" ,
108
+ "actorType" ,
102
109
},
103
110
)
104
111
m .Collector .RegisterMetricList ("workflowLatestRunTimestamp" , m .prometheus .workflowLatestRunTimestamp , true )
@@ -111,8 +118,11 @@ func (m *MetricsCollectorGithubWorkflows) Setup(collector *collector.Collector)
111
118
[]string {
112
119
"org" ,
113
120
"repo" ,
121
+ "workflowID" ,
114
122
"workflow" ,
115
123
"branch" ,
124
+ "actorLogin" ,
125
+ "actorType" ,
116
126
},
117
127
)
118
128
m .Collector .RegisterMetricList ("workflowConsecutiveFailures" , m .prometheus .workflowConsecutiveFailures , true )
@@ -297,11 +307,12 @@ func (m *MetricsCollectorGithubWorkflows) Collect(callback chan<- func()) {
297
307
// workflow info metrics
298
308
for _ , workflow := range workflows {
299
309
labels := prometheus.Labels {
300
- "org" : org ,
301
- "repo" : repo .GetName (),
302
- "workflow" : workflow .GetName (),
303
- "state" : workflow .GetState (),
304
- "path" : workflow .GetPath (),
310
+ "org" : org ,
311
+ "repo" : repo .GetName (),
312
+ "workflowID" : fmt .Sprintf ("%v" , workflow .GetID ()),
313
+ "workflow" : workflow .GetName (),
314
+ "state" : workflow .GetState (),
315
+ "path" : workflow .GetPath (),
305
316
}
306
317
for labelName , labelValue := range propLabels {
307
318
labels [labelName ] = labelValue
@@ -362,10 +373,13 @@ func (m *MetricsCollectorGithubWorkflows) collectLatestRun(org string, repo *git
362
373
labels := prometheus.Labels {
363
374
"org" : org ,
364
375
"repo" : repo .GetName (),
376
+ "workflowID" : fmt .Sprintf ("%v" , workflowRun .GetWorkflowID ()),
365
377
"workflow" : workflowRun .GetName (),
366
378
"event" : workflowRun .GetEvent (),
367
379
"branch" : workflowRun .GetHeadBranch (),
368
380
"conclusion" : workflowRun .GetConclusion (),
381
+ "actorLogin" : workflowRun .Actor .GetLogin (),
382
+ "actorType" : workflowRun .Actor .GetType (),
369
383
}
370
384
371
385
runMetric .AddInfo (labels )
@@ -376,7 +390,10 @@ func (m *MetricsCollectorGithubWorkflows) collectLatestRun(org string, repo *git
376
390
func (m * MetricsCollectorGithubWorkflows ) collectConsecutiveFailures (org string , repo * github.Repository , workflowRun []* github.WorkflowRun , callback chan <- func ()) {
377
391
consecutiveFailuresMetric := m .Collector .GetMetricList ("workflowConsecutiveFailures" )
378
392
379
- consecutiveFailMap := map [int64 ]int64 {}
393
+ consecutiveFailMap := map [int64 ]* struct {
394
+ count int64
395
+ labels prometheus.Labels
396
+ }{}
380
397
consecutiveFinishedMap := map [int64 ]bool {}
381
398
382
399
for _ , row := range workflowRun {
@@ -398,7 +415,21 @@ func (m *MetricsCollectorGithubWorkflows) collectConsecutiveFailures(org string,
398
415
}
399
416
400
417
if _ , exists := consecutiveFailMap [workflowId ]; ! exists {
401
- consecutiveFailMap [workflowId ] = 0
418
+ consecutiveFailMap [workflowId ] = & struct {
419
+ count int64
420
+ labels prometheus.Labels
421
+ }{
422
+ count : 0 ,
423
+ labels : prometheus.Labels {
424
+ "org" : org ,
425
+ "repo" : repo .GetName (),
426
+ "workflowID" : fmt .Sprintf ("%v" , workflowRun .GetWorkflowID ()),
427
+ "workflow" : workflowRun .GetName (),
428
+ "branch" : workflowRun .GetHeadBranch (),
429
+ "actorLogin" : workflowRun .Actor .GetLogin (),
430
+ "actorType" : workflowRun .Actor .GetType (),
431
+ },
432
+ }
402
433
consecutiveFinishedMap [workflowId ] = false
403
434
}
404
435
@@ -411,17 +442,14 @@ func (m *MetricsCollectorGithubWorkflows) collectConsecutiveFailures(org string,
411
442
case "" :
412
443
continue
413
444
case "failure" :
414
- consecutiveFailMap [workflowId ]++
445
+ consecutiveFailMap [workflowId ]. count ++
415
446
case "success" :
416
447
consecutiveFinishedMap [workflowId ] = true
417
448
}
449
+ }
418
450
419
- labels := prometheus.Labels {
420
- "org" : org ,
421
- "repo" : repo .GetName (),
422
- "workflow" : workflowRun .GetName (),
423
- "branch" : workflowRun .GetHeadBranch (),
424
- }
425
- consecutiveFailuresMetric .Add (labels , float64 (consecutiveFailMap [workflowId ]))
451
+ // process metrics
452
+ for _ , row := range consecutiveFailMap {
453
+ consecutiveFailuresMetric .Add (row .labels , float64 (row .count ))
426
454
}
427
455
}
0 commit comments