mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-24 22:23:02 +00:00
fixup! Test workqueue metrics
change units to seconds Kubernetes-commit: 578962d934df19cb2cb7ec0536dcb76f53951e68
This commit is contained in:
parent
e403f1715c
commit
cc2731ad7e
@ -80,7 +80,7 @@ type defaultQueueMetrics struct {
|
|||||||
processingStartTimes map[t]time.Time
|
processingStartTimes map[t]time.Time
|
||||||
|
|
||||||
// how long have current threads been working?
|
// how long have current threads been working?
|
||||||
unfinishedWorkMicroseconds SettableGaugeMetric
|
unfinishedWorkSeconds SettableGaugeMetric
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultQueueMetrics) add(item t) {
|
func (m *defaultQueueMetrics) add(item t) {
|
||||||
@ -124,7 +124,9 @@ func (m *defaultQueueMetrics) updateUnfinishedWork() {
|
|||||||
for _, t := range m.processingStartTimes {
|
for _, t := range m.processingStartTimes {
|
||||||
total += m.sinceInMicroseconds(t)
|
total += m.sinceInMicroseconds(t)
|
||||||
}
|
}
|
||||||
m.unfinishedWorkMicroseconds.Set(total)
|
// Convert to seconds; microseconds is unhelpfully granular for this.
|
||||||
|
total /= 1000000
|
||||||
|
m.unfinishedWorkSeconds.Set(total)
|
||||||
}
|
}
|
||||||
|
|
||||||
type noMetrics struct{}
|
type noMetrics struct{}
|
||||||
@ -161,7 +163,7 @@ type MetricsProvider interface {
|
|||||||
NewAddsMetric(name string) CounterMetric
|
NewAddsMetric(name string) CounterMetric
|
||||||
NewLatencyMetric(name string) SummaryMetric
|
NewLatencyMetric(name string) SummaryMetric
|
||||||
NewWorkDurationMetric(name string) SummaryMetric
|
NewWorkDurationMetric(name string) SummaryMetric
|
||||||
NewUnfinishedWorkMicrosecondsMetric(name string) SettableGaugeMetric
|
NewUnfinishedWorkSecondsMetric(name string) SettableGaugeMetric
|
||||||
NewRetriesMetric(name string) CounterMetric
|
NewRetriesMetric(name string) CounterMetric
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +185,7 @@ func (_ noopMetricsProvider) NewWorkDurationMetric(name string) SummaryMetric {
|
|||||||
return noopMetric{}
|
return noopMetric{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ noopMetricsProvider) NewUnfinishedWorkMicrosecondsMetric(name string) SettableGaugeMetric {
|
func (_ noopMetricsProvider) NewUnfinishedWorkSecondsMetric(name string) SettableGaugeMetric {
|
||||||
return noopMetric{}
|
return noopMetric{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,14 +215,14 @@ func (f *queueMetricsFactory) newQueueMetrics(name string, clock clock.Clock) qu
|
|||||||
return noMetrics{}
|
return noMetrics{}
|
||||||
}
|
}
|
||||||
return &defaultQueueMetrics{
|
return &defaultQueueMetrics{
|
||||||
clock: clock,
|
clock: clock,
|
||||||
depth: mp.NewDepthMetric(name),
|
depth: mp.NewDepthMetric(name),
|
||||||
adds: mp.NewAddsMetric(name),
|
adds: mp.NewAddsMetric(name),
|
||||||
latency: mp.NewLatencyMetric(name),
|
latency: mp.NewLatencyMetric(name),
|
||||||
workDuration: mp.NewWorkDurationMetric(name),
|
workDuration: mp.NewWorkDurationMetric(name),
|
||||||
unfinishedWorkMicroseconds: mp.NewUnfinishedWorkMicrosecondsMetric(name),
|
unfinishedWorkSeconds: mp.NewUnfinishedWorkSecondsMetric(name),
|
||||||
addTimes: map[t]time.Time{},
|
addTimes: map[t]time.Time{},
|
||||||
processingStartTimes: map[t]time.Time{},
|
processingStartTimes: map[t]time.Time{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ func (m *testMetricsProvider) NewWorkDurationMetric(name string) SummaryMetric {
|
|||||||
return &m.duration
|
return &m.duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *testMetricsProvider) NewUnfinishedWorkMicrosecondsMetric(name string) SettableGaugeMetric {
|
func (m *testMetricsProvider) NewUnfinishedWorkSecondsMetric(name string) SettableGaugeMetric {
|
||||||
return &m.unfinished
|
return &m.unfinished
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ func TestMetrics(t *testing.T) {
|
|||||||
c.Step(time.Millisecond)
|
c.Step(time.Millisecond)
|
||||||
<-ch
|
<-ch
|
||||||
mp.unfinished.notifyCh = nil
|
mp.unfinished.notifyCh = nil
|
||||||
if e, a := 1000.0, mp.unfinished.gaugeValue(); e != a {
|
if e, a := .001, mp.unfinished.gaugeValue(); e != a {
|
||||||
t.Errorf("expected %v, got %v", e, a)
|
t.Errorf("expected %v, got %v", e, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user