22
"istio.io/istio/pilot/pkg/features"
23
"istio.io/istio/pkg/monitoring"
27
queueIDTag = monitoring.CreateLabel("queueID")
28
enableMetric = monitoring.WithEnabled(func() bool {
29
return features.EnableControllerQueueMetrics
31
depth = monitoring.NewGauge("pilot_worker_queue_depth", "Depth of the controller queues", enableMetric)
33
latency = monitoring.NewDistribution("pilot_worker_queue_latency",
34
"Latency before the item is processed", []float64{.01, .1, .2, .5, 1, 3, 5}, enableMetric)
36
workDuration = monitoring.NewDistribution("pilot_worker_queue_duration",
37
"Time taken to process an item", []float64{.01, .1, .2, .5, 1, 3, 5}, enableMetric)
40
type queueMetrics struct {
41
depth monitoring.Metric
42
latency monitoring.Metric
43
workDuration monitoring.Metric
45
clock clock.WithTicker
49
func (m *queueMetrics) sinceInSeconds(start time.Time) float64 {
50
return m.clock.Since(start).Seconds()
53
func newQueueMetrics(id string) *queueMetrics {
56
depth: depth.With(queueIDTag.Value(id)),
57
workDuration: workDuration.With(queueIDTag.Value(id)),
58
latency: latency.With(queueIDTag.Value(id)),
59
clock: clock.RealClock{},