From a25e0f4adbd98b4141ba6e1ac74782223f33e786 Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Wed, 15 Feb 2023 15:00:53 +0100 Subject: [PATCH] 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. --- internal/prometheus/job_metrics.go | 6 +++--- internal/worker/server.go | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/prometheus/job_metrics.go b/internal/prometheus/job_metrics.go index d233983ec..9de8799b8 100644 --- a/internal/prometheus/job_metrics.go +++ b/internal/prometheus/job_metrics.go @@ -52,17 +52,17 @@ var ( Subsystem: WorkerSubsystem, 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}, - }, []string{"type", "tenant"}) + }, []string{"type", "tenant", "arch"}) ) func EnqueueJobMetrics(jobType, tenant string) { 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() { diff := started.Sub(pending).Seconds() - JobWaitDuration.WithLabelValues(jobType, tenant).Observe(diff) + JobWaitDuration.WithLabelValues(jobType, tenant, arch).Observe(diff) PendingJobs.WithLabelValues(jobType, tenant).Dec() RunningJobs.WithLabelValues(jobType, tenant).Inc() } diff --git a/internal/worker/server.go b/internal/worker/server.go index d9d93cd5c..11159d662 100644 --- a/internal/worker/server.go +++ b/internal/worker/server.go @@ -557,9 +557,14 @@ func (s *Server) requestJob(ctx context.Context, arch string, jobTypes []string, // specify dequeuing restrictions. For now, we only have one // restriction: arch for osbuild jobs. 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 { if t == JobTypeOSBuild { t = t + ":" + arch + archPromLabel = arch } if t == JobTypeManifestIDOnly { 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 }