mirror of https://github.com/k3s-io/k3s
Merge pull request #72334 from danielqsj/kp
Change proxy metrics to conform metrics guidelinespull/564/head
commit
b8d6de320f
|
@ -639,7 +639,8 @@ func (proxier *Proxier) syncProxyRules() {
|
|||
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
metrics.SyncProxyRulesLatency.Observe(metrics.SinceInMicroseconds(start))
|
||||
metrics.SyncProxyRulesLatency.Observe(metrics.SinceInSeconds(start))
|
||||
metrics.DeprecatedSyncProxyRulesLatency.Observe(metrics.SinceInMicroseconds(start))
|
||||
klog.V(4).Infof("syncProxyRules took %v", time.Since(start))
|
||||
}()
|
||||
// don't sync rules till we've received services and endpoints
|
||||
|
|
|
@ -719,7 +719,8 @@ func (proxier *Proxier) syncProxyRules() {
|
|||
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
metrics.SyncProxyRulesLatency.Observe(metrics.SinceInMicroseconds(start))
|
||||
metrics.SyncProxyRulesLatency.Observe(metrics.SinceInSeconds(start))
|
||||
metrics.DeprecatedSyncProxyRulesLatency.Observe(metrics.SinceInMicroseconds(start))
|
||||
klog.V(4).Infof("syncProxyRules took %v", time.Since(start))
|
||||
}()
|
||||
// don't sync rules till we've received services and endpoints
|
||||
|
|
|
@ -28,10 +28,20 @@ const kubeProxySubsystem = "kubeproxy"
|
|||
var (
|
||||
// SyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules.
|
||||
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 is the latency of one round of kube-proxy syncing proxy rules.
|
||||
DeprecatedSyncProxyRulesLatency = prometheus.NewHistogram(
|
||||
prometheus.HistogramOpts{
|
||||
Subsystem: kubeProxySubsystem,
|
||||
Name: "sync_proxy_rules_latency_microseconds",
|
||||
Help: "SyncProxyRules latency",
|
||||
Help: "(Deprecated) SyncProxyRules latency in microseconds",
|
||||
Buckets: prometheus.ExponentialBuckets(1000, 2, 15),
|
||||
},
|
||||
)
|
||||
|
@ -43,6 +53,7 @@ var registerMetricsOnce sync.Once
|
|||
func RegisterMetrics() {
|
||||
registerMetricsOnce.Do(func() {
|
||||
prometheus.MustRegister(SyncProxyRulesLatency)
|
||||
prometheus.MustRegister(DeprecatedSyncProxyRulesLatency)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -50,3 +61,8 @@ func RegisterMetrics() {
|
|||
func SinceInMicroseconds(start time.Time) float64 {
|
||||
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
|
||||
}
|
||||
|
||||
// SinceInSeconds gets the time since the specified start in seconds.
|
||||
func SinceInSeconds(start time.Time) float64 {
|
||||
return time.Since(start).Seconds()
|
||||
}
|
||||
|
|
|
@ -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: "(Deprecated) 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()
|
||||
}
|
||||
|
|
|
@ -938,7 +938,8 @@ func (proxier *Proxier) syncProxyRules() {
|
|||
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
SyncProxyRulesLatency.Observe(sinceInMicroseconds(start))
|
||||
SyncProxyRulesLatency.Observe(sinceInSeconds(start))
|
||||
DeprecatedSyncProxyRulesLatency.Observe(sinceInMicroseconds(start))
|
||||
klog.V(4).Infof("syncProxyRules took %v", time.Since(start))
|
||||
}()
|
||||
// don't sync rules till we've received services and endpoints
|
||||
|
|
Loading…
Reference in New Issue