@@ -12,14 +12,14 @@ import (
1212// This file is mostly a copy of unexported code from
1313// https://github.com/kubernetes/kubernetes/blob/1d8828ce707ed9dd7a6a9756385419cce1d202ac/staging/src/k8s.io/client-go/util/workqueue/metrics.go
1414//
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.
1716
1817type queueMetrics [T comparable ] interface {
1918 add (item T )
2019 get (item T )
2120 done (item T )
2221 updateUnfinishedWork ()
22+ retry ()
2323}
2424
2525func 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
3737 added : sets.Set [T ]{},
3838 addTimes : map [T ]time.Time {},
3939 processingStartTimes : map [T ]time.Time {},
40+ retries : mp .NewRetriesMetric (name ),
4041 }
4142}
4243
@@ -61,6 +62,8 @@ type defaultQueueMetrics[T comparable] struct {
6162 // how long have current threads been working?
6263 unfinishedWorkSeconds workqueue.SettableGaugeMetric
6364 longestRunningProcessor workqueue.SettableGaugeMetric
65+
66+ retries workqueue.CounterMetric
6467}
6568
6669func (m * defaultQueueMetrics [T ]) add (item T ) {
@@ -135,9 +138,14 @@ func (m *defaultQueueMetrics[T]) sinceInSeconds(start time.Time) float64 {
135138 return m .clock .Since (start ).Seconds ()
136139}
137140
141+ func (m * defaultQueueMetrics [T ]) retry () {
142+ m .retries .Inc ()
143+ }
144+
138145type noMetrics [T any ] struct {}
139146
140147func (noMetrics [T ]) add (item T ) {}
141148func (noMetrics [T ]) get (item T ) {}
142149func (noMetrics [T ]) done (item T ) {}
143150func (noMetrics [T ]) updateUnfinishedWork () {}
151+ func (noMetrics [T ]) retry () {}
0 commit comments