metrics: build jobs arch label

Add the architecture label to build jobs
which will enable filtering and monitoring
build jobs by architecture. Build job results
contain the `arch` field in the results struct,
this is then used to pass to the metrics, where
there is a value, otherwise it is set to an
empty string.
This commit is contained in:
Gianluca Zuccarelli 2022-07-20 16:32:15 +01:00 committed by Tomáš Hozza
parent 8b4aff3857
commit 9f4e765657
2 changed files with 16 additions and 7 deletions

View file

@ -571,7 +571,8 @@ func (s *Server) FinishJob(token uuid.UUID, result json.RawMessage) error {
logrus.Errorf("error finding job status: %v", err)
} else {
statusCode := clienterrors.GetStatusCode(jobResult.JobError)
prometheus.FinishJobMetrics(status.Started, status.Finished, status.Canceled, jobType, channel, statusCode)
arch := getBuildJobArch(jobType, result)
prometheus.FinishJobMetrics(status.Started, status.Finished, status.Canceled, jobType, channel, arch, statusCode)
}
// Move artifacts from the temporary location to the final job
@ -587,6 +588,14 @@ func (s *Server) FinishJob(token uuid.UUID, result json.RawMessage) error {
return nil
}
func getBuildJobArch(jobType string, jobResult json.RawMessage) string {
if !strings.HasPrefix(jobType, "osbuild:") {
return ""
}
arch := strings.Split(jobType, ":")[1]
return arch
}
// apiHandlers implements api.ServerInterface - the http api route handlers
// generated from api/openapi.yml. This is a separate object, because these
// handlers should not be exposed on the `Server` object.