in metrics/internal/pipelines/observer.go [198:224]
func (o *observer) updateMetrics(pipelines []*gitlab.PipelineInfo) {
counters := make(map[string]float64)
for _, status := range statusLabels {
counters[status] = 0
}
for _, pipeline := range pipelines {
status := pipeline.Status
pipelineLogger := o.log.WithFields(logrus.Fields{
"ref": pipeline.Ref,
"status": status,
})
pipelineLogger.Info(pipeline.WebURL)
if err := o.metric.CheckLabels([]string{pipeline.Status}); err != nil {
pipelineLogger.WithError(err).Warn("unknown status")
status = "unknown"
}
counters[status]++
}
for status, count := range counters {
o.metric.Set(count, status)
}
}