Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Make metric for dequeued tasks in bloom-gateway a Histogram #14413

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/bloomgateway/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type workerMetrics struct {
dequeueDuration *prometheus.HistogramVec
queueDuration *prometheus.HistogramVec
processDuration *prometheus.HistogramVec
tasksDequeued *prometheus.CounterVec
tasksDequeued *prometheus.HistogramVec
tasksProcessed *prometheus.CounterVec
blocksNotAvailable *prometheus.CounterVec
blockQueryLatency *prometheus.HistogramVec
Expand Down Expand Up @@ -147,11 +147,12 @@ func newWorkerMetrics(registerer prometheus.Registerer, namespace, subsystem str
Name: "process_duration_seconds",
Help: "Time spent processing tasks in seconds",
}, append(labels, "status")),
tasksDequeued: r.NewCounterVec(prometheus.CounterOpts{
tasksDequeued: r.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "tasks_dequeued_total",
Help: "Total amount of tasks that the worker dequeued from the queue",
Name: "tasks_dequeued",
Help: "Total amount of tasks that the worker dequeued from the queue at once",
Buckets: prometheus.ExponentialBuckets(1, 2, 8), // [1, 2, ..., 128]
}, append(labels, "status")),
tasksProcessed: r.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Expand Down
4 changes: 2 additions & 2 deletions pkg/bloomgateway/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (w *worker) running(_ context.Context) error {
if err == queue.ErrStopped && len(items) == 0 {
return err
}
w.metrics.tasksDequeued.WithLabelValues(w.id, labelFailure).Inc()
w.metrics.tasksDequeued.WithLabelValues(w.id, labelFailure).Observe(1)
level.Error(w.logger).Log("msg", "failed to dequeue tasks", "err", err, "items", len(items))
}
idx = newIdx
Expand All @@ -86,7 +86,7 @@ func (w *worker) running(_ context.Context) error {
continue
}

w.metrics.tasksDequeued.WithLabelValues(w.id, labelSuccess).Add(float64(len(items)))
w.metrics.tasksDequeued.WithLabelValues(w.id, labelSuccess).Observe(float64(len(items)))

tasks := make([]Task, 0, len(items))
for _, item := range items {
Expand Down
Loading