Skip to content

Commit

Permalink
Optional registration of metrics, new way
Browse files Browse the repository at this point in the history
  • Loading branch information
ra-grover committed Jul 20, 2023
1 parent 2d5717e commit bdc472c
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions pkg/queue/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,17 @@ import (
)

var (
queueIDTag = monitoring.MustCreateLabel("queueID")

depth = monitoring.NewGauge("pilot_worker_queue_depth", "Depth of the controller queues", monitoring.WithLabels(queueIDTag))
queueIDTag = monitoring.CreateLabel("queueID")
enableMetric = monitoring.WithEnabled(func() bool {
return features.EnableControllerQueueMetrics
})
depth = monitoring.NewGauge("pilot_worker_queue_depth", "Depth of the controller queues", enableMetric)

latency = monitoring.NewDistribution(
"pilot_worker_queue_latency",
"Latency before the item is processed",
[]float64{.01, .1, .2, .5, 1, 3, 5},
monitoring.WithLabels(queueIDTag))
latency = monitoring.NewDistribution("pilot_worker_queue_latency",
"Latency before the item is processed", []float64{.01, .1, .2, .5, 1, 3, 5}, enableMetric)

workDuration = monitoring.NewDistribution("pilot_worker_queue_duration",
"Time taken to process an item",
[]float64{.01, .1, .2, .5, 1, 3, 5},
monitoring.WithLabels(queueIDTag))
"Time taken to process an item", []float64{.01, .1, .2, .5, 1, 3, 5}, enableMetric)
)

type queueMetrics struct {
Expand All @@ -62,12 +59,3 @@ func newQueueMetrics(id string) *queueMetrics {
clock: clock.RealClock{},
}
}

func init() {
enableQueueMetrics := func() bool {
return features.EnableControllerQueueMetrics
}
monitoring.RegisterIf(depth, enableQueueMetrics)
monitoring.RegisterIf(latency, enableQueueMetrics)
monitoring.RegisterIf(workDuration, enableQueueMetrics)
}

0 comments on commit bdc472c

Please sign in to comment.