mirror of https://github.com/k3s-io/k3s
Using histogram metrics instead of summary
parent
b828bc1a50
commit
42214c5ac4
|
@ -65,23 +65,25 @@ func (prometheusMetricsProvider) NewAddsMetric(name string) workqueue.CounterMet
|
|||
return adds
|
||||
}
|
||||
|
||||
func (prometheusMetricsProvider) NewLatencyMetric(name string) workqueue.SummaryMetric {
|
||||
latency := prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
func (prometheusMetricsProvider) NewLatencyMetric(name string) workqueue.HistogramMetric {
|
||||
latency := prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: QueueLatencyKey,
|
||||
Help: "How long in seconds an item stays in workqueue before being requested.",
|
||||
ConstLabels: prometheus.Labels{"name": name},
|
||||
Buckets: prometheus.ExponentialBuckets(10e-9, 10, 10),
|
||||
})
|
||||
prometheus.Register(latency)
|
||||
return latency
|
||||
}
|
||||
|
||||
func (prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.SummaryMetric {
|
||||
workDuration := prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
func (prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.HistogramMetric {
|
||||
workDuration := prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: WorkDurationKey,
|
||||
Help: "How long in seconds processing an item from workqueue takes.",
|
||||
ConstLabels: prometheus.Labels{"name": name},
|
||||
Buckets: prometheus.ExponentialBuckets(10e-9, 10, 10),
|
||||
})
|
||||
prometheus.Register(workDuration)
|
||||
return workDuration
|
||||
|
|
|
@ -57,6 +57,11 @@ type SummaryMetric interface {
|
|||
Observe(float64)
|
||||
}
|
||||
|
||||
// HistogramMetric counts individual observations.
|
||||
type HistogramMetric interface {
|
||||
Observe(float64)
|
||||
}
|
||||
|
||||
type noopMetric struct{}
|
||||
|
||||
func (noopMetric) Inc() {}
|
||||
|
@ -73,9 +78,9 @@ type defaultQueueMetrics struct {
|
|||
// total number of adds handled by a workqueue
|
||||
adds CounterMetric
|
||||
// how long an item stays in a workqueue
|
||||
latency SummaryMetric
|
||||
latency HistogramMetric
|
||||
// how long processing an item from a workqueue takes
|
||||
workDuration SummaryMetric
|
||||
workDuration HistogramMetric
|
||||
addTimes map[t]time.Time
|
||||
processingStartTimes map[t]time.Time
|
||||
|
||||
|
@ -190,8 +195,8 @@ func (m *defaultRetryMetrics) retry() {
|
|||
type MetricsProvider interface {
|
||||
NewDepthMetric(name string) GaugeMetric
|
||||
NewAddsMetric(name string) CounterMetric
|
||||
NewLatencyMetric(name string) SummaryMetric
|
||||
NewWorkDurationMetric(name string) SummaryMetric
|
||||
NewLatencyMetric(name string) HistogramMetric
|
||||
NewWorkDurationMetric(name string) HistogramMetric
|
||||
NewUnfinishedWorkSecondsMetric(name string) SettableGaugeMetric
|
||||
NewLongestRunningProcessorSecondsMetric(name string) SettableGaugeMetric
|
||||
NewRetriesMetric(name string) CounterMetric
|
||||
|
@ -214,11 +219,11 @@ func (_ noopMetricsProvider) NewAddsMetric(name string) CounterMetric {
|
|||
return noopMetric{}
|
||||
}
|
||||
|
||||
func (_ noopMetricsProvider) NewLatencyMetric(name string) SummaryMetric {
|
||||
func (_ noopMetricsProvider) NewLatencyMetric(name string) HistogramMetric {
|
||||
return noopMetric{}
|
||||
}
|
||||
|
||||
func (_ noopMetricsProvider) NewWorkDurationMetric(name string) SummaryMetric {
|
||||
func (_ noopMetricsProvider) NewWorkDurationMetric(name string) HistogramMetric {
|
||||
return noopMetric{}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,11 +155,11 @@ func (m *testMetricsProvider) NewAddsMetric(name string) CounterMetric {
|
|||
return &m.adds
|
||||
}
|
||||
|
||||
func (m *testMetricsProvider) NewLatencyMetric(name string) SummaryMetric {
|
||||
func (m *testMetricsProvider) NewLatencyMetric(name string) HistogramMetric {
|
||||
return &m.latency
|
||||
}
|
||||
|
||||
func (m *testMetricsProvider) NewWorkDurationMetric(name string) SummaryMetric {
|
||||
func (m *testMetricsProvider) NewWorkDurationMetric(name string) HistogramMetric {
|
||||
return &m.duration
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue