Skip to content

Commit 6f70f78

Browse files
author
Han Kang
committed
add some documentation around the metrics stability migration changes for clarity
1 parent 3a50917 commit 6f70f78

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

pkg/volume/util/metrics.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,47 @@ const (
3030
statusFailUnknown = "fail-unknown"
3131
)
3232

33+
/*
34+
* By default, all the following metrics are defined as falling under
35+
* ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes)
36+
*
37+
* Promoting the stability level of the metric is a responsibility of the component owner, since it
38+
* involves explicitly acknowledging support for the metric across multiple releases, in accordance with
39+
* the metric stability policy.
40+
*/
3341
var storageOperationMetric = metrics.NewHistogramVec(
3442
&metrics.HistogramOpts{
35-
Name: "storage_operation_duration_seconds",
36-
Help: "Storage operation duration",
37-
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600},
43+
Name: "storage_operation_duration_seconds",
44+
Help: "Storage operation duration",
45+
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600},
3846
StabilityLevel: metrics.ALPHA,
3947
},
4048
[]string{"volume_plugin", "operation_name"},
4149
)
4250

4351
var storageOperationErrorMetric = metrics.NewCounterVec(
4452
&metrics.CounterOpts{
45-
Name: "storage_operation_errors_total",
46-
Help: "Storage operation errors",
53+
Name: "storage_operation_errors_total",
54+
Help: "Storage operation errors",
4755
StabilityLevel: metrics.ALPHA,
4856
},
4957
[]string{"volume_plugin", "operation_name"},
5058
)
5159

5260
var storageOperationStatusMetric = metrics.NewCounterVec(
5361
&metrics.CounterOpts{
54-
Name: "storage_operation_status_count",
55-
Help: "Storage operation return statuses count",
62+
Name: "storage_operation_status_count",
63+
Help: "Storage operation return statuses count",
5664
StabilityLevel: metrics.ALPHA,
5765
},
5866
[]string{"volume_plugin", "operation_name", "status"},
5967
)
6068

6169
var storageOperationEndToEndLatencyMetric = metrics.NewHistogramVec(
6270
&metrics.HistogramOpts{
63-
Name: "volume_operation_total_seconds",
64-
Help: "Storage operation end to end duration in seconds",
65-
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600},
71+
Name: "volume_operation_total_seconds",
72+
Help: "Storage operation end to end duration in seconds",
73+
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600},
6674
StabilityLevel: metrics.ALPHA,
6775
},
6876
[]string{"plugin_name", "operation_name"},
@@ -73,6 +81,8 @@ func init() {
7381
}
7482

7583
func registerMetrics() {
84+
// legacyregistry is the internal k8s wrapper around the prometheus
85+
// global registry, used specifically for metric stability enforcement
7686
legacyregistry.MustRegister(storageOperationMetric)
7787
legacyregistry.MustRegister(storageOperationErrorMetric)
7888
legacyregistry.MustRegister(storageOperationStatusMetric)

staging/src/k8s.io/component-base/metrics/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ var (
3232
// RegisterBuildInfo registers the build and version info in a metadata metric in prometheus
3333
func RegisterBuildInfo(r KubeRegistry) {
3434
info := version.Get()
35-
buildInfo.WithLabelValues(info.Major, info.Minor, info.GitVersion, info.GitCommit, info.GitTreeState, info.BuildDate, info.GoVersion, info.Compiler, info.Platform).Set(1)
3635
r.MustRegister(buildInfo)
36+
buildInfo.WithLabelValues(info.Major, info.Minor, info.GitVersion, info.GitCommit, info.GitTreeState, info.BuildDate, info.GoVersion, info.Compiler, info.Platform).Set(1)
3737
}

0 commit comments

Comments
 (0)