@@ -12,14 +12,14 @@ import (
12
12
// This file is mostly a copy of unexported code from
13
13
// https://github.com/kubernetes/kubernetes/blob/1d8828ce707ed9dd7a6a9756385419cce1d202ac/staging/src/k8s.io/client-go/util/workqueue/metrics.go
14
14
//
15
- // The only difference is the addition of mapLock in defaultQueueMetrics, we want to avoid the need of synchronizing updateUnfinishedWork()
16
- // with the queue.
15
+ // The only two differences are the addition of mapLock in defaultQueueMetrics and converging retryMetrics into queueMetrics.
17
16
18
17
type queueMetrics [T comparable ] interface {
19
18
add (item T )
20
19
get (item T )
21
20
done (item T )
22
21
updateUnfinishedWork ()
22
+ retry ()
23
23
}
24
24
25
25
func newQueueMetrics [T comparable ](mp workqueue.MetricsProvider , name string , clock clock.Clock ) queueMetrics [T ] {
@@ -37,6 +37,7 @@ func newQueueMetrics[T comparable](mp workqueue.MetricsProvider, name string, cl
37
37
added : sets.Set [T ]{},
38
38
addTimes : map [T ]time.Time {},
39
39
processingStartTimes : map [T ]time.Time {},
40
+ retries : mp .NewRetriesMetric (name ),
40
41
}
41
42
}
42
43
@@ -61,6 +62,8 @@ type defaultQueueMetrics[T comparable] struct {
61
62
// how long have current threads been working?
62
63
unfinishedWorkSeconds workqueue.SettableGaugeMetric
63
64
longestRunningProcessor workqueue.SettableGaugeMetric
65
+
66
+ retries workqueue.CounterMetric
64
67
}
65
68
66
69
func (m * defaultQueueMetrics [T ]) add (item T ) {
@@ -135,9 +138,14 @@ func (m *defaultQueueMetrics[T]) sinceInSeconds(start time.Time) float64 {
135
138
return m .clock .Since (start ).Seconds ()
136
139
}
137
140
141
+ func (m * defaultQueueMetrics [T ]) retry () {
142
+ m .retries .Inc ()
143
+ }
144
+
138
145
type noMetrics [T any ] struct {}
139
146
140
147
func (noMetrics [T ]) add (item T ) {}
141
148
func (noMetrics [T ]) get (item T ) {}
142
149
func (noMetrics [T ]) done (item T ) {}
143
150
func (noMetrics [T ]) updateUnfinishedWork () {}
151
+ func (noMetrics [T ]) retry () {}
0 commit comments