Skip to content

component-base: introduce metrics api #131572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions staging/src/k8s.io/component-base/metrics/api/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package

// Package v1 contains the configuration API for metrics.
//
// The intention is to only have a single version of this API, potentially with
// new fields added over time in a backwards-compatible manner. Fields for
// alpha or beta features are allowed as long as they are defined so that not
// changing the defaults leaves those features disabled.
//
// The "v1" package name is just a reminder that API compatibility rules apply,
// not an indication of the stability of all features covered by it.

package v1 // import "k8s.io/component-base/metrics/api/v1"
26 changes: 26 additions & 0 deletions staging/src/k8s.io/component-base/metrics/api/v1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
"k8s.io/component-base/metrics"
)

// MetricsConfiguration contains metrics options.
type MetricsConfiguration struct {
metrics.Options `json:",inline"`
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions staging/src/k8s.io/component-base/metrics/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,22 @@ import (
)

// Options has all parameters needed for exposing metrics from components
// +k8s:deepcopy-gen=true
type Options struct {
ShowHiddenMetricsForVersion string
DisabledMetrics []string
AllowListMapping map[string]string
AllowListMappingManifest string
// ShowHiddenMetricsForVersion is the previous version for which you want to show hidden metrics.
// Only the previous minor version is meaningful, other values will not be allowed.
// The format is <major>.<minor>, e.g.: '1.16'.
// The purpose of this format is make sure you have the opportunity to notice if the next release hides additional metrics,
// rather than being surprised when they are permanently removed in the release after that.
ShowHiddenMetricsForVersion string `json:"showHiddenMetricsForVersion,omitempty"`
// DisabledMetrics is a list of fully qualified metric names that should be disabled.
// Disabling metrics is higher in precedence than showing hidden metrics.
DisabledMetrics []string `json:"disabledMetrics,omitempty"`
// AllowListMapping is the map from metric-label to value allow-list of this label.
// 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".
AllowListMapping map[string]string `json:"allowListMapping,omitempty"`
// The path to the manifest file that contains the allow-list mapping. Provided for convenience over AllowListMapping.
AllowListMappingManifest string `json:"allowListMappingManifest,omitempty"`
}

// NewOptions returns default metrics options
Expand Down
50 changes: 50 additions & 0 deletions staging/src/k8s.io/component-base/metrics/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.