prometheus:: add arch label to dequeue metrics

Only add the arch label for osbuild job types, as the finish metrics
behave similarly. Having arch labels on dequeue metrics for any other
job type (but not on the finish metrics) would produce weird results.
This commit is contained in:
Sanne Raymaekers 2023-02-15 15:00:53 +01:00
parent d7e2e5d740
commit a25e0f4adb
2 changed files with 9 additions and 4 deletions

View file

@ -52,17 +52,17 @@ var (
Subsystem: WorkerSubsystem, Subsystem: WorkerSubsystem,
Help: "Duration a job spends on the queue.", Help: "Duration a job spends on the queue.",
Buckets: []float64{.1, .2, .5, 1, 2, 4, 8, 16, 32, 40, 48, 64, 96, 128, 160, 192, 224, 256, 320, 382, 448, 512, 640, 768, 896, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 10752}, Buckets: []float64{.1, .2, .5, 1, 2, 4, 8, 16, 32, 40, 48, 64, 96, 128, 160, 192, 224, 256, 320, 382, 448, 512, 640, 768, 896, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 10752},
}, []string{"type", "tenant"}) }, []string{"type", "tenant", "arch"})
) )
func EnqueueJobMetrics(jobType, tenant string) { func EnqueueJobMetrics(jobType, tenant string) {
PendingJobs.WithLabelValues(jobType, tenant).Inc() PendingJobs.WithLabelValues(jobType, tenant).Inc()
} }
func DequeueJobMetrics(pending time.Time, started time.Time, jobType, tenant string) { func DequeueJobMetrics(pending time.Time, started time.Time, jobType, tenant, arch string) {
if !started.IsZero() && !pending.IsZero() { if !started.IsZero() && !pending.IsZero() {
diff := started.Sub(pending).Seconds() diff := started.Sub(pending).Seconds()
JobWaitDuration.WithLabelValues(jobType, tenant).Observe(diff) JobWaitDuration.WithLabelValues(jobType, tenant, arch).Observe(diff)
PendingJobs.WithLabelValues(jobType, tenant).Dec() PendingJobs.WithLabelValues(jobType, tenant).Dec()
RunningJobs.WithLabelValues(jobType, tenant).Inc() RunningJobs.WithLabelValues(jobType, tenant).Inc()
} }

View file

@ -557,9 +557,14 @@ func (s *Server) requestJob(ctx context.Context, arch string, jobTypes []string,
// specify dequeuing restrictions. For now, we only have one // specify dequeuing restrictions. For now, we only have one
// restriction: arch for osbuild jobs. // restriction: arch for osbuild jobs.
jts := []string{} jts := []string{}
// Only set the label used for prometheus metrics when it's an osbuild job. Otherwise the
// dequeue metrics would set the label for all job types, while the finish metrics only set
// it for osbuild jobs.
var archPromLabel string
for _, t := range jobTypes { for _, t := range jobTypes {
if t == JobTypeOSBuild { if t == JobTypeOSBuild {
t = t + ":" + arch t = t + ":" + arch
archPromLabel = arch
} }
if t == JobTypeManifestIDOnly { if t == JobTypeManifestIDOnly {
return uuid.Nil, uuid.Nil, "", nil, nil, ErrInvalidJobType return uuid.Nil, uuid.Nil, "", nil, nil, ErrInvalidJobType
@ -618,7 +623,7 @@ func (s *Server) requestJob(ctx context.Context, arch string, jobTypes []string,
} }
} }
prometheus.DequeueJobMetrics(pending, jobInfo.JobStatus.Started, jobInfo.JobType, jobInfo.Channel) prometheus.DequeueJobMetrics(pending, jobInfo.JobStatus.Started, jobInfo.JobType, jobInfo.Channel, archPromLabel)
return return
} }