Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3db1050

Browse filesBrowse files
committed
component-base: introduce metrics api
Introduce metrics API for configuring options in a non-breaking manner.
1 parent 8aa1d33 commit 3db1050
Copy full SHA for 3db1050

File tree

5 files changed

+159
-4
lines changed
Filter options

5 files changed

+159
-4
lines changed
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// +k8s:deepcopy-gen=package
18+
19+
// Package v1 contains the configuration API for metrics.
20+
//
21+
// The intention is to only have a single version of this API, potentially with
22+
// new fields added over time in a backwards-compatible manner. Fields for
23+
// alpha or beta features are allowed as long as they are defined so that not
24+
// changing the defaults leaves those features disabled.
25+
//
26+
// The "v1" package name is just a reminder that API compatibility rules apply,
27+
// not an indication of the stability of all features covered by it.
28+
29+
package v1 // import "k8s.io/component-base/metrics/api/v1"
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
"k8s.io/component-base/metrics"
21+
)
22+
23+
// MetricsConfiguration contains metrics options.
24+
type MetricsConfiguration struct {
25+
metrics.Options `json:",inline"`
26+
}

‎staging/src/k8s.io/component-base/metrics/api/v1/zz_generated.deepcopy.go

Copy file name to clipboardExpand all lines: staging/src/k8s.io/component-base/metrics/api/v1/zz_generated.deepcopy.go
+39Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎staging/src/k8s.io/component-base/metrics/options.go

Copy file name to clipboardExpand all lines: staging/src/k8s.io/component-base/metrics/options.go
+15-4Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,22 @@ import (
2727
)
2828

2929
// Options has all parameters needed for exposing metrics from components
30+
// +k8s:deepcopy-gen=true
3031
type Options struct {
31-
ShowHiddenMetricsForVersion string
32-
DisabledMetrics []string
33-
AllowListMapping map[string]string
34-
AllowListMappingManifest string
32+
// ShowHiddenMetricsForVersion is the previous version for which you want to show hidden metrics.
33+
// Only the previous minor version is meaningful, other values will not be allowed.
34+
// The format is <major>.<minor>, e.g.: '1.16'.
35+
// The purpose of this format is make sure you have the opportunity to notice if the next release hides additional metrics,
36+
// rather than being surprised when they are permanently removed in the release after that.
37+
ShowHiddenMetricsForVersion string `json:"showHiddenMetricsForVersion,omitempty"`
38+
// DisabledMetrics is a list of fully qualified metric names that should be disabled.
39+
// Disabling metrics is higher in precedence than showing hidden metrics.
40+
DisabledMetrics []string `json:"disabledMetrics,omitempty"`
41+
// AllowListMapping is the map from metric-label to value allow-list of this label.
42+
// The key's format is <MetricName>,<LabelName>, while its value is a list of allowed values for that label of that metric. For e.g., "metric1,label1": "v1,v2,v3".
43+
AllowListMapping map[string]string `json:"allowListMapping,omitempty"`
44+
// The path to the manifest file that contains the allow-list mapping. Provided for convenience over AllowListMapping.
45+
AllowListMappingManifest string `json:"allowListMappingManifest,omitempty"`
3546
}
3647

3748
// NewOptions returns default metrics options

‎staging/src/k8s.io/component-base/metrics/zz_generated.deepcopy.go

Copy file name to clipboardExpand all lines: staging/src/k8s.io/component-base/metrics/zz_generated.deepcopy.go
+50Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.