Skip to content

Commit 0aa1588

Browse files
Add guidelines for metric graduation
Co-authored-by: Marek Siarkowicz <[email protected]>
1 parent 2867130 commit 0aa1588

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

contributors/devel/sig-instrumentation/metric-instrumentation.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ internal and external.
2222

2323
## Quick Start
2424

25+
### Adding a New Metric
26+
2527
The following describes the basic steps required to add a new metric (in Go).
2628

2729
1. Import "k8s.io/component-base/metrics" for metrics and "k8s.io/component-base/metrics/legacyregistry" to register your declared metrics.
@@ -67,6 +69,31 @@ first calling WithLabelValues if your metric has any labels
6769
requestCounter.WithLabelValues(*verb, *resource, client, strconv.Itoa(*httpCode)).Inc()
6870
```
6971

72+
### Graduating an Existing Metric
73+
74+
When graduating a metric from Alpha to Beta or from Beta to Stable, the following requirements must be met. For more information on stability levels and their guarantees, see [Metrics Stability](#metrics-stability).
75+
76+
#### Graduating to Beta
77+
78+
1. **Testing requirement**: The metric must have a corresponding test that validates:
79+
- The metric is registered and emitted correctly
80+
- The metric has the expected labels and values under known conditions
81+
82+
2. **Documentation**: Ensure the metric has a clear and accurate help text description.
83+
84+
3. **API Review**: Graduating a metric to Beta requires an API review by SIG Instrumentation, as it represents a contractual API agreement. See the [API Review](/contributors/devel/sig-instrumentation/metric-stability.md#api-review) section in the metrics stability documentation.
85+
86+
#### Graduating to Stable
87+
88+
The metric must meet all of the requirements for Beta graduation.
89+
90+
1. **Testing requirement**:
91+
- The metric must be included in the [stable metrics list](https://github.com/kubernetes/kubernetes/blob/master/test/instrumentation/testdata/stable-metrics-list.yaml)
92+
- See the [instrumentation test README](https://github.com/kubernetes/kubernetes/tree/master/test/instrumentation/README.md) for steps on how to generate this file correctly
93+
94+
2. **Stability validation**: The metric should have been at Beta stability for at least one release to ensure it has been sufficiently validated in production environments.
95+
96+
3. **API Review**: Marking a metric as stable is a commitment by the owning SIG to maintain stability guarantees. The owning SIG leads must review and approve the graduation first. Additionally, approval from SIG Instrumentation is required as it represents a contractual API agreement. See the [API Review](/contributors/devel/sig-instrumentation/metric-stability.md#api-review) section in the metrics stability documentation.
7097

7198
## Instrumentation types
7299

contributors/devel/sig-instrumentation/metric-stability.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ From an ingestion point of view, it is backwards-compatible to add or remove pos
4848

4949
## API Review
5050

51-
Graduating a metric to a stable state is a contractual API agreement, as such, it would be desirable to require an api-review (to sig-instrumentation) for graduating or deprecating a metric (in line with current Kubernetes [api-review processes](https://github.com/kubernetes/community/blob/master/sig-architecture/api-review-process.md)).
51+
Graduating a metric to beta or stable is a contractual API agreement (in line with current Kubernetes [api-review processes](https://github.com/kubernetes/community/blob/master/sig-architecture/api-review-process.md)).
52+
53+
For **Beta** metrics, approval from SIG Instrumentation is required.
54+
55+
For **Stable** metrics, marking a metric as stable is a commitment by the owning SIG to maintain stability guarantees. The owning SIG leads must review and approve the graduation first. Additionally, approval from SIG Instrumentation is required.
5256

5357
We use a verification script to flag stable metric changes for review by SIG Instrumentation approvers.
5458

0 commit comments

Comments
 (0)