func (m *defaultQueueMetrics) sinceInSeconds(start time.Time) float64 {
	return m.clock.Since(start).Seconds()
}
Gets the time since the specified start in seconds.
package workqueue
import (
	"sync"
	"time"
	"k8s.io/apimachinery/pkg/util/clock"
)
type queueMetrics interface {
	add(item t)
	get(item t)
	done(item t)
	updateUnfinishedWork()
}
type GaugeMetric interface {
	Inc()
	Dec()
}
type SettableGaugeMetric interface {
	Set(float64)
}
type CounterMetric interface {
	Inc()
}
type SummaryMetric interface {
	Observe(float64)
}
type HistogramMetric interface {
	Observe(float64)
}
type noopMetric struct{}
func (noopMetric) Inc()            {}
func (noopMetric) Dec()            {}
func (noopMetric) Set(float64)     {}
func (noopMetric) Observe(float64) {}
type defaultQueueMetrics struct {
	clock clock.Clock
	depth GaugeMetric
	adds CounterMetric
	latency HistogramMetric
	workDuration         HistogramMetric
	addTimes             map[t]time.Time
	processingStartTimes map[t]time.Time
	unfinishedWorkSeconds   SettableGaugeMetric
	longestRunningProcessor SettableGaugeMetric
}
func (m *defaultQueueMetrics) add(item t) {
	if m == nil {
		return
	}
	m.adds.Inc()
	m.depth.Inc()
	if _, exists := m.addTimes[item]; !exists {
		m.addTimes[item] = m.clock.Now()
	}
}
func (m *defaultQueueMetrics) get(item t) {
	if m == nil {
		return
	}
	m.depth.Dec()
	m.processingStartTimes[item] = m.clock.Now()
	if startTime, exists := m.addTimes[item]; exists {
		m.latency.Observe(m.sinceInSeconds(startTime))
		delete(m.addTimes, item)
	}
}
func (m *defaultQueueMetrics) done(item t) {
	if m == nil {
		return
	}
	if startTime, exists := m.processingStartTimes[item]; exists {
		m.workDuration.Observe(m.sinceInSeconds(startTime))
		delete(m.processingStartTimes, item)
	}
}
func (m *defaultQueueMetrics) updateUnfinishedWork() {
	var total float64
	var oldest float64
	for _, t := range m.processingStartTimes {
		age := m.sinceInSeconds(t)
		total += age
		if age > oldest {
			oldest = age
		}
	}
	m.unfinishedWorkSeconds.Set(total)
	m.longestRunningProcessor.Set(oldest)
}
type noMetrics struct{}
func (noMetrics) add(item t)            {}
func (noMetrics) get(item t)            {}
func (noMetrics) done(item t)           {}
func (noMetrics) updateUnfinishedWork() {}