Change proxy metrics to conform guideline

This commit is contained in:
danielqsj
2018-12-26 17:25:10 +08:00
parent 5252352ad8
commit 8975e62254
5 changed files with 39 additions and 5 deletions

View File

@@ -27,10 +27,19 @@ const kubeProxySubsystem = "kubeproxy"
var (
SyncProxyRulesLatency = prometheus.NewHistogram(
prometheus.HistogramOpts{
Subsystem: kubeProxySubsystem,
Name: "sync_proxy_rules_latency_seconds",
Help: "SyncProxyRules latency in seconds",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 15),
},
)
DeprecatedSyncProxyRulesLatency = prometheus.NewHistogram(
prometheus.HistogramOpts{
Subsystem: kubeProxySubsystem,
Name: "sync_proxy_rules_latency_microseconds",
Help: "SyncProxyRules latency",
Help: "SyncProxyRules latency in microseconds",
Buckets: prometheus.ExponentialBuckets(1000, 2, 15),
},
)
@@ -41,6 +50,7 @@ var registerMetricsOnce sync.Once
func RegisterMetrics() {
registerMetricsOnce.Do(func() {
prometheus.MustRegister(SyncProxyRulesLatency)
prometheus.MustRegister(DeprecatedSyncProxyRulesLatency)
})
}
@@ -48,3 +58,8 @@ func RegisterMetrics() {
func sinceInMicroseconds(start time.Time) float64 {
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
}
// Gets the time since the specified start in seconds.
func sinceInSeconds(start time.Time) float64 {
return time.Since(start).Seconds()
}