mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +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"
|
||||
startTime := time.Now()
|
||||
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)
|
||||
recordError(operation, err)
|
||||
|
@ -80,8 +80,8 @@ const (
|
||||
KubeletConfigKeyLabelKey = "node_config_kubelet_key"
|
||||
|
||||
// Metrics keys for RuntimeClass
|
||||
RunPodSandboxLatenciesKey = "run_podsandbox_latencies"
|
||||
RunPodSandboxErrorsKey = "run_podsandbox_errors"
|
||||
RunPodSandboxDurationKey = "run_podsandbox_duration_seconds"
|
||||
RunPodSandboxErrorsKey = "run_podsandbox_errors_total"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -338,11 +338,13 @@ var (
|
||||
Help: "This metric is true (1) if the node is experiencing a configuration-related error, false (0) otherwise.",
|
||||
},
|
||||
)
|
||||
RunPodSandboxLatencies = prometheus.NewSummaryVec(
|
||||
prometheus.SummaryOpts{
|
||||
RunPodSandboxDuration = prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Subsystem: KubeletSubsystem,
|
||||
Name: RunPodSandboxLatenciesKey,
|
||||
Help: "Latencies in microseconds of the run_podsandbox operations. Broken down by RuntimeClass.",
|
||||
Name: RunPodSandboxDurationKey,
|
||||
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"},
|
||||
)
|
||||
@ -407,7 +409,7 @@ func SinceInMicroseconds(start time.Time) float64 {
|
||||
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 {
|
||||
return time.Since(start).Seconds()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user