Merge pull request #73820 from haiyanmeng/runtimeclass

Fit RuntimeClass metrics to prometheus conventions
This commit is contained in:
Kubernetes Prow Robot 2019-02-22 16:14:59 -08:00 committed by GitHub
commit 95856e30c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -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)

View File

@ -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()
}