@@ -2,6 +2,7 @@ package main
22
33import (
44 "context"
5+ "strings"
56 "time"
67
78 "github.com/prometheus/client_golang/prometheus"
@@ -306,8 +307,9 @@ func (m *MetricsCollectorBuild) collectBuildsTimeline(ctx context.Context, logge
306307 for _ , build := range list .List {
307308 timelineRecordList , _ := AzureDevopsClient .ListBuildTimeline (project .Id , int64ToString (build .Id ))
308309 for _ , timelineRecord := range timelineRecordList .List {
309- switch recordType := timelineRecord .RecordType ; recordType {
310- case "Stage" :
310+ recordType := timelineRecord .RecordType ;
311+ switch strings .ToLower (recordType ) {
312+ case "stage" :
311313 buildStageMetric .Add (prometheus.Labels {
312314 "projectID" : project .Id ,
313315 "buildID" : int64ToString (build .Id ),
@@ -380,7 +382,7 @@ func (m *MetricsCollectorBuild) collectBuildsTimeline(ctx context.Context, logge
380382 "type" : "duration" ,
381383 }, timelineRecord .FinishTime .Sub (timelineRecord .StartTime ))
382384
383- case "Phase " :
385+ case "phase " :
384386 buildPhaseMetric .Add (prometheus.Labels {
385387 "projectID" : project .Id ,
386388 "buildID" : int64ToString (build .Id ),
@@ -458,7 +460,8 @@ func (m *MetricsCollectorBuild) collectBuildsTimeline(ctx context.Context, logge
458460 "result" : timelineRecord .Result ,
459461 "type" : "duration" ,
460462 }, timelineRecord .FinishTime .Sub (timelineRecord .StartTime ))
461- case "Job" :
463+
464+ case "job" :
462465 buildJobMetric .Add (prometheus.Labels {
463466 "projectID" : project .Id ,
464467 "buildID" : int64ToString (build .Id ),
@@ -536,7 +539,8 @@ func (m *MetricsCollectorBuild) collectBuildsTimeline(ctx context.Context, logge
536539 "result" : timelineRecord .Result ,
537540 "type" : "duration" ,
538541 }, timelineRecord .FinishTime .Sub (timelineRecord .StartTime ))
539- case "Task" :
542+
543+ case "task" :
540544 buildTaskMetric .Add (prometheus.Labels {
541545 "projectID" : project .Id ,
542546 "buildID" : int64ToString (build .Id ),
@@ -614,9 +618,7 @@ func (m *MetricsCollectorBuild) collectBuildsTimeline(ctx context.Context, logge
614618 "result" : timelineRecord .Result ,
615619 "type" : "duration" ,
616620 }, timelineRecord .FinishTime .Sub (timelineRecord .StartTime ))
617-
618621 }
619-
620622 }
621623 }
622624
0 commit comments