mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #73820 from haiyanmeng/runtimeclass
Fit RuntimeClass metrics to prometheus conventions
This commit is contained in:
commit
95856e30c4
@ -183,7 +183,7 @@ func (in instrumentedRuntimeService) RunPodSandbox(config *runtimeapi.PodSandbox
|
|||||||
const operation = "run_podsandbox"
|
const operation = "run_podsandbox"
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
defer recordOperation(operation, startTime)
|
defer recordOperation(operation, startTime)
|
||||||
defer metrics.RunPodSandboxLatencies.WithLabelValues(runtimeHandler).Observe(metrics.SinceInMicroseconds(startTime))
|
defer metrics.RunPodSandboxDuration.WithLabelValues(runtimeHandler).Observe(metrics.SinceInSeconds(startTime))
|
||||||
|
|
||||||
out, err := in.service.RunPodSandbox(config, runtimeHandler)
|
out, err := in.service.RunPodSandbox(config, runtimeHandler)
|
||||||
recordError(operation, err)
|
recordError(operation, err)
|
||||||
|
@ -80,8 +80,8 @@ const (
|
|||||||
KubeletConfigKeyLabelKey = "node_config_kubelet_key"
|
KubeletConfigKeyLabelKey = "node_config_kubelet_key"
|
||||||
|
|
||||||
// Metrics keys for RuntimeClass
|
// Metrics keys for RuntimeClass
|
||||||
RunPodSandboxLatenciesKey = "run_podsandbox_latencies"
|
RunPodSandboxDurationKey = "run_podsandbox_duration_seconds"
|
||||||
RunPodSandboxErrorsKey = "run_podsandbox_errors"
|
RunPodSandboxErrorsKey = "run_podsandbox_errors_total"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -338,11 +338,13 @@ var (
|
|||||||
Help: "This metric is true (1) if the node is experiencing a configuration-related error, false (0) otherwise.",
|
Help: "This metric is true (1) if the node is experiencing a configuration-related error, false (0) otherwise.",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
RunPodSandboxLatencies = prometheus.NewSummaryVec(
|
RunPodSandboxDuration = prometheus.NewHistogramVec(
|
||||||
prometheus.SummaryOpts{
|
prometheus.HistogramOpts{
|
||||||
Subsystem: KubeletSubsystem,
|
Subsystem: KubeletSubsystem,
|
||||||
Name: RunPodSandboxLatenciesKey,
|
Name: RunPodSandboxDurationKey,
|
||||||
Help: "Latencies in microseconds of the run_podsandbox operations. Broken down by RuntimeClass.",
|
Help: "Duration in seconds of the run_podsandbox operations. Broken down by RuntimeClass.",
|
||||||
|
// Use DefBuckets for now, will customize the buckets if necessary.
|
||||||
|
Buckets: prometheus.DefBuckets,
|
||||||
},
|
},
|
||||||
[]string{"runtime_handler"},
|
[]string{"runtime_handler"},
|
||||||
)
|
)
|
||||||
@ -407,7 +409,7 @@ func SinceInMicroseconds(start time.Time) float64 {
|
|||||||
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
|
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the time since the specified start in seconds.
|
// SinceInSeconds gets the time since the specified start in seconds.
|
||||||
func SinceInSeconds(start time.Time) float64 {
|
func SinceInSeconds(start time.Time) float64 {
|
||||||
return time.Since(start).Seconds()
|
return time.Since(start).Seconds()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user