mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
rebase: update kubernetes to v1.25.0
update kubernetes to latest v1.25.0 release. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
f47839d73d
commit
e3bf375035
69
vendor/k8s.io/component-base/metrics/gauge.go
generated
vendored
69
vendor/k8s.io/component-base/metrics/gauge.go
generated
vendored
@ -18,6 +18,7 @@ package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
@ -33,7 +34,11 @@ type Gauge struct {
|
||||
selfCollector
|
||||
}
|
||||
|
||||
// NewGauge returns an object which satisfies the kubeCollector and KubeGauge interfaces.
|
||||
var _ GaugeMetric = &Gauge{}
|
||||
var _ Registerable = &Gauge{}
|
||||
var _ kubeCollector = &Gauge{}
|
||||
|
||||
// NewGauge returns an object which satisfies the kubeCollector, Registerable, and Gauge interfaces.
|
||||
// However, the object returned will not measure anything unless the collector is first
|
||||
// registered, since the metric is lazily instantiated.
|
||||
func NewGauge(opts *GaugeOpts) *Gauge {
|
||||
@ -88,9 +93,14 @@ type GaugeVec struct {
|
||||
originalLabels []string
|
||||
}
|
||||
|
||||
// NewGaugeVec returns an object which satisfies the kubeCollector and KubeGaugeVec interfaces.
|
||||
var _ GaugeVecMetric = &GaugeVec{}
|
||||
var _ Registerable = &GaugeVec{}
|
||||
var _ kubeCollector = &GaugeVec{}
|
||||
|
||||
// NewGaugeVec returns an object which satisfies the kubeCollector, Registerable, and GaugeVecMetric interfaces.
|
||||
// However, the object returned will not measure anything unless the collector is first
|
||||
// registered, since the metric is lazily instantiated.
|
||||
// registered, since the metric is lazily instantiated, and only members extracted after
|
||||
// registration will actually measure anything.
|
||||
func NewGaugeVec(opts *GaugeOpts, labels []string) *GaugeVec {
|
||||
opts.StabilityLevel.setDefaults()
|
||||
|
||||
@ -130,26 +140,55 @@ func (v *GaugeVec) initializeDeprecatedMetric() {
|
||||
v.initializeMetric()
|
||||
}
|
||||
|
||||
// Default Prometheus behavior actually results in the creation of a new metric
|
||||
// if a metric with the unique label values is not found in the underlying stored metricMap.
|
||||
func (v *GaugeVec) WithLabelValuesChecked(lvs ...string) (GaugeMetric, error) {
|
||||
if !v.IsCreated() {
|
||||
if v.IsHidden() {
|
||||
return noop, nil
|
||||
}
|
||||
return noop, errNotRegistered // return no-op gauge
|
||||
}
|
||||
if v.LabelValueAllowLists != nil {
|
||||
v.LabelValueAllowLists.ConstrainToAllowedList(v.originalLabels, lvs)
|
||||
}
|
||||
elt, err := v.GaugeVec.GetMetricWithLabelValues(lvs...)
|
||||
return elt, err
|
||||
}
|
||||
|
||||
// Default Prometheus Vec behavior is that member extraction results in creation of a new element
|
||||
// if one with the unique label values is not found in the underlying stored metricMap.
|
||||
// This means that if this function is called but the underlying metric is not registered
|
||||
// (which means it will never be exposed externally nor consumed), the metric will exist in memory
|
||||
// for perpetuity (i.e. throughout application lifecycle).
|
||||
//
|
||||
// For reference: https://github.com/prometheus/client_golang/blob/v0.9.2/prometheus/gauge.go#L190-L208
|
||||
//
|
||||
// In contrast, the Vec behavior in this package is that member extraction before registration
|
||||
// returns a permanent noop object.
|
||||
|
||||
// WithLabelValues returns the GaugeMetric for the given slice of label
|
||||
// values (same order as the VariableLabels in Desc). If that combination of
|
||||
// label values is accessed for the first time, a new GaugeMetric is created IFF the gaugeVec
|
||||
// has been registered to a metrics registry.
|
||||
func (v *GaugeVec) WithLabelValues(lvs ...string) GaugeMetric {
|
||||
ans, err := v.WithLabelValuesChecked(lvs...)
|
||||
if err == nil || ErrIsNotRegistered(err) {
|
||||
return ans
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
|
||||
func (v *GaugeVec) WithChecked(labels map[string]string) (GaugeMetric, error) {
|
||||
if !v.IsCreated() {
|
||||
return noop // return no-op gauge
|
||||
if v.IsHidden() {
|
||||
return noop, nil
|
||||
}
|
||||
return noop, errNotRegistered // return no-op gauge
|
||||
}
|
||||
if v.LabelValueAllowLists != nil {
|
||||
v.LabelValueAllowLists.ConstrainToAllowedList(v.originalLabels, lvs)
|
||||
v.LabelValueAllowLists.ConstrainLabelMap(labels)
|
||||
}
|
||||
return v.GaugeVec.WithLabelValues(lvs...)
|
||||
elt, err := v.GaugeVec.GetMetricWith(labels)
|
||||
return elt, err
|
||||
}
|
||||
|
||||
// With returns the GaugeMetric for the given Labels map (the label names
|
||||
@ -157,13 +196,11 @@ func (v *GaugeVec) WithLabelValues(lvs ...string) GaugeMetric {
|
||||
// accessed for the first time, a new GaugeMetric is created IFF the gaugeVec has
|
||||
// been registered to a metrics registry.
|
||||
func (v *GaugeVec) With(labels map[string]string) GaugeMetric {
|
||||
if !v.IsCreated() {
|
||||
return noop // return no-op gauge
|
||||
ans, err := v.WithChecked(labels)
|
||||
if err == nil || ErrIsNotRegistered(err) {
|
||||
return ans
|
||||
}
|
||||
if v.LabelValueAllowLists != nil {
|
||||
v.LabelValueAllowLists.ConstrainLabelMap(labels)
|
||||
}
|
||||
return v.GaugeVec.With(labels)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Delete deletes the metric where the variable labels are the same as those
|
||||
@ -219,6 +256,10 @@ func (v *GaugeVec) WithContext(ctx context.Context) *GaugeVecWithContext {
|
||||
}
|
||||
}
|
||||
|
||||
func (v *GaugeVec) InterfaceWithContext(ctx context.Context) GaugeVecMetric {
|
||||
return v.WithContext(ctx)
|
||||
}
|
||||
|
||||
// GaugeVecWithContext is the wrapper of GaugeVec with context.
|
||||
type GaugeVecWithContext struct {
|
||||
*GaugeVec
|
||||
|
Reference in New Issue
Block a user