mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-26 07:02:01 +00:00
Allow custom metric provider for retry metrics
Kubernetes-commit: a60624ffbc265d61b35cab16ea9ded485909f3ed
This commit is contained in:
parent
66fa9d308f
commit
21b4553e44
@ -71,7 +71,7 @@ func NewDelayingQueueWithConfig(config DelayingQueueConfig) DelayingInterface {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return newDelayingQueue(config.Clock, config.Queue, config.Name)
|
return newDelayingQueue(config.Clock, config.Queue, config.Name, config.MetricsProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDelayingQueueWithCustomQueue constructs a new workqueue with ability to
|
// NewDelayingQueueWithCustomQueue constructs a new workqueue with ability to
|
||||||
@ -100,14 +100,14 @@ func NewDelayingQueueWithCustomClock(clock clock.WithTicker, name string) Delayi
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDelayingQueue(clock clock.WithTicker, q Interface, name string) *delayingType {
|
func newDelayingQueue(clock clock.WithTicker, q Interface, name string, provider MetricsProvider) *delayingType {
|
||||||
ret := &delayingType{
|
ret := &delayingType{
|
||||||
Interface: q,
|
Interface: q,
|
||||||
clock: clock,
|
clock: clock,
|
||||||
heartbeat: clock.NewTicker(maxWait),
|
heartbeat: clock.NewTicker(maxWait),
|
||||||
stopCh: make(chan struct{}),
|
stopCh: make(chan struct{}),
|
||||||
waitingForAddCh: make(chan *waitFor, 1000),
|
waitingForAddCh: make(chan *waitFor, 1000),
|
||||||
metrics: newRetryMetrics(name),
|
metrics: newRetryMetrics(name, provider),
|
||||||
}
|
}
|
||||||
|
|
||||||
go ret.waitingLoop()
|
go ret.waitingLoop()
|
||||||
|
@ -244,13 +244,18 @@ func (f *queueMetricsFactory) newQueueMetrics(name string, clock clock.Clock) qu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRetryMetrics(name string) retryMetrics {
|
func newRetryMetrics(name string, provider MetricsProvider) retryMetrics {
|
||||||
var ret *defaultRetryMetrics
|
var ret *defaultRetryMetrics
|
||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if provider == nil {
|
||||||
|
provider = globalMetricsFactory.metricsProvider
|
||||||
|
}
|
||||||
|
|
||||||
return &defaultRetryMetrics{
|
return &defaultRetryMetrics{
|
||||||
retries: globalMetricsFactory.metricsProvider.NewRetriesMetric(name),
|
retries: provider.NewRetriesMetric(name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ func TestRateLimitingQueue(t *testing.T) {
|
|||||||
heartbeat: fakeClock.NewTicker(maxWait),
|
heartbeat: fakeClock.NewTicker(maxWait),
|
||||||
stopCh: make(chan struct{}),
|
stopCh: make(chan struct{}),
|
||||||
waitingForAddCh: make(chan *waitFor, 1000),
|
waitingForAddCh: make(chan *waitFor, 1000),
|
||||||
metrics: newRetryMetrics(""),
|
metrics: newRetryMetrics("", nil),
|
||||||
}
|
}
|
||||||
queue.DelayingInterface = delayingQueue
|
queue.DelayingInterface = delayingQueue
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user