Bump sigs.k8s.io/controller-runtime to v0.14.4 (#5507)
* Bump sigs.k8s.io/controller-runtime to v0.14.4 * Update gofmt
This commit is contained in:
43
vendor/k8s.io/component-base/metrics/buckets.go
generated
vendored
Normal file
43
vendor/k8s.io/component-base/metrics/buckets.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright 2022 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 metrics
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
// DefBuckets is a wrapper for prometheus.DefBuckets
|
||||
var DefBuckets = prometheus.DefBuckets
|
||||
|
||||
// LinearBuckets is a wrapper for prometheus.LinearBuckets.
|
||||
func LinearBuckets(start, width float64, count int) []float64 {
|
||||
return prometheus.LinearBuckets(start, width, count)
|
||||
}
|
||||
|
||||
// ExponentialBuckets is a wrapper for prometheus.ExponentialBuckets.
|
||||
func ExponentialBuckets(start, factor float64, count int) []float64 {
|
||||
return prometheus.ExponentialBuckets(start, factor, count)
|
||||
}
|
||||
|
||||
// MergeBuckets merges buckets together
|
||||
func MergeBuckets(buckets ...[]float64) []float64 {
|
||||
result := make([]float64, 1)
|
||||
for _, s := range buckets {
|
||||
result = append(result, s...)
|
||||
}
|
||||
return result
|
||||
}
|
||||
6
vendor/k8s.io/component-base/metrics/collector.go
generated
vendored
6
vendor/k8s.io/component-base/metrics/collector.go
generated
vendored
@@ -45,9 +45,9 @@ type StableCollector interface {
|
||||
HiddenMetrics() []string
|
||||
}
|
||||
|
||||
// BaseStableCollector which implements almost all of the methods defined by StableCollector
|
||||
// BaseStableCollector which implements almost all methods defined by StableCollector
|
||||
// is a convenient assistant for custom collectors.
|
||||
// It is recommend that inherit BaseStableCollector when implementing custom collectors.
|
||||
// It is recommended to inherit BaseStableCollector when implementing custom collectors.
|
||||
type BaseStableCollector struct {
|
||||
descriptors map[string]*Desc // stores all descriptors by pair<fqName, Desc>, these are collected from DescribeWithStability().
|
||||
registerable map[string]*Desc // stores registerable descriptors by pair<fqName, Desc>, is a subset of descriptors.
|
||||
@@ -62,7 +62,7 @@ func (bsc *BaseStableCollector) DescribeWithStability(ch chan<- *Desc) {
|
||||
}
|
||||
|
||||
// Describe sends all descriptors to the provided channel.
|
||||
// It intend to be called by prometheus registry.
|
||||
// It intended to be called by prometheus registry.
|
||||
func (bsc *BaseStableCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||
for _, d := range bsc.registerable {
|
||||
ch <- d.toPrometheusDesc()
|
||||
|
||||
4
vendor/k8s.io/component-base/metrics/counter.go
generated
vendored
4
vendor/k8s.io/component-base/metrics/counter.go
generated
vendored
@@ -44,7 +44,7 @@ func NewCounter(opts *CounterOpts) *Counter {
|
||||
|
||||
kc := &Counter{
|
||||
CounterOpts: opts,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
kc.setPrometheusCounter(noop)
|
||||
kc.lazyInit(kc, BuildFQName(opts.Namespace, opts.Subsystem, opts.Name))
|
||||
@@ -129,7 +129,7 @@ func NewCounterVec(opts *CounterOpts, labels []string) *CounterVec {
|
||||
CounterVec: noopCounterVec,
|
||||
CounterOpts: opts,
|
||||
originalLabels: labels,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
cv.lazyInit(cv, fqName)
|
||||
return cv
|
||||
|
||||
39
vendor/k8s.io/component-base/metrics/features/kube_features.go
generated
vendored
Normal file
39
vendor/k8s.io/component-base/metrics/features/kube_features.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2022 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 features
|
||||
|
||||
import (
|
||||
"k8s.io/component-base/featuregate"
|
||||
)
|
||||
|
||||
const (
|
||||
// owner: @logicalhan
|
||||
// kep: https://kep.k8s.io/3466
|
||||
// alpha: v1.26
|
||||
ComponentSLIs featuregate.Feature = "ComponentSLIs"
|
||||
)
|
||||
|
||||
func featureGates() map[featuregate.Feature]featuregate.FeatureSpec {
|
||||
return map[featuregate.Feature]featuregate.FeatureSpec{
|
||||
ComponentSLIs: {Default: false, PreRelease: featuregate.Alpha},
|
||||
}
|
||||
}
|
||||
|
||||
// AddFeatureGates adds all feature gates used by this package.
|
||||
func AddFeatureGates(mutableFeatureGate featuregate.MutableFeatureGate) error {
|
||||
return mutableFeatureGate.Add(featureGates())
|
||||
}
|
||||
4
vendor/k8s.io/component-base/metrics/gauge.go
generated
vendored
4
vendor/k8s.io/component-base/metrics/gauge.go
generated
vendored
@@ -46,7 +46,7 @@ func NewGauge(opts *GaugeOpts) *Gauge {
|
||||
|
||||
kc := &Gauge{
|
||||
GaugeOpts: opts,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
kc.setPrometheusGauge(noop)
|
||||
kc.lazyInit(kc, BuildFQName(opts.Namespace, opts.Subsystem, opts.Name))
|
||||
@@ -115,7 +115,7 @@ func NewGaugeVec(opts *GaugeOpts, labels []string) *GaugeVec {
|
||||
GaugeVec: noopGaugeVec,
|
||||
GaugeOpts: opts,
|
||||
originalLabels: labels,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
cv.lazyInit(cv, fqName)
|
||||
return cv
|
||||
|
||||
17
vendor/k8s.io/component-base/metrics/histogram.go
generated
vendored
17
vendor/k8s.io/component-base/metrics/histogram.go
generated
vendored
@@ -23,19 +23,6 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
// DefBuckets is a wrapper for prometheus.DefBuckets
|
||||
var DefBuckets = prometheus.DefBuckets
|
||||
|
||||
// LinearBuckets is a wrapper for prometheus.LinearBuckets.
|
||||
func LinearBuckets(start, width float64, count int) []float64 {
|
||||
return prometheus.LinearBuckets(start, width, count)
|
||||
}
|
||||
|
||||
// ExponentialBuckets is a wrapper for prometheus.ExponentialBuckets.
|
||||
func ExponentialBuckets(start, factor float64, count int) []float64 {
|
||||
return prometheus.ExponentialBuckets(start, factor, count)
|
||||
}
|
||||
|
||||
// Histogram is our internal representation for our wrapping struct around prometheus
|
||||
// histograms. Summary implements both kubeCollector and ObserverMetric
|
||||
type Histogram struct {
|
||||
@@ -52,7 +39,7 @@ func NewHistogram(opts *HistogramOpts) *Histogram {
|
||||
|
||||
h := &Histogram{
|
||||
HistogramOpts: opts,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
h.setPrometheusHistogram(noopMetric{})
|
||||
h.lazyInit(h, BuildFQName(opts.Namespace, opts.Subsystem, opts.Name))
|
||||
@@ -119,7 +106,7 @@ func NewHistogramVec(opts *HistogramOpts, labels []string) *HistogramVec {
|
||||
HistogramVec: noopHistogramVec,
|
||||
HistogramOpts: opts,
|
||||
originalLabels: labels,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
v.lazyInit(v, fqName)
|
||||
return v
|
||||
|
||||
8
vendor/k8s.io/component-base/metrics/legacyregistry/registry.go
generated
vendored
8
vendor/k8s.io/component-base/metrics/legacyregistry/registry.go
generated
vendored
@@ -20,6 +20,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/collectors"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
"k8s.io/component-base/metrics"
|
||||
@@ -44,10 +45,9 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
//nolint:staticcheck // SA1019 - replacement function still calls prometheus.NewProcessCollector().
|
||||
RawMustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))
|
||||
//nolint:staticcheck // SA1019 - replacement function still calls prometheus.NewGoCollector().
|
||||
RawMustRegister(prometheus.NewGoCollector())
|
||||
RawMustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
|
||||
RawMustRegister(collectors.NewGoCollector(collectors.WithGoCollectorRuntimeMetrics(collectors.MetricsAll)))
|
||||
defaultRegistry.RegisterMetaMetrics()
|
||||
}
|
||||
|
||||
// Handler returns an HTTP handler for the DefaultGatherer. It is
|
||||
|
||||
9
vendor/k8s.io/component-base/metrics/metric.go
generated
vendored
9
vendor/k8s.io/component-base/metrics/metric.go
generated
vendored
@@ -72,6 +72,7 @@ type lazyMetric struct {
|
||||
markDeprecationOnce sync.Once
|
||||
createOnce sync.Once
|
||||
self kubeCollector
|
||||
stabilityLevel StabilityLevel
|
||||
}
|
||||
|
||||
func (r *lazyMetric) IsCreated() bool {
|
||||
@@ -149,6 +150,7 @@ func (r *lazyMetric) Create(version *semver.Version) bool {
|
||||
if r.IsHidden() {
|
||||
return false
|
||||
}
|
||||
|
||||
r.createOnce.Do(func() {
|
||||
r.createLock.Lock()
|
||||
defer r.createLock.Unlock()
|
||||
@@ -159,6 +161,13 @@ func (r *lazyMetric) Create(version *semver.Version) bool {
|
||||
r.self.initializeMetric()
|
||||
}
|
||||
})
|
||||
sl := r.stabilityLevel
|
||||
deprecatedV := r.self.DeprecatedVersion()
|
||||
dv := ""
|
||||
if deprecatedV != nil {
|
||||
dv = deprecatedV.String()
|
||||
}
|
||||
registeredMetrics.WithLabelValues(string(sl), dv).Inc()
|
||||
return r.IsCreated()
|
||||
}
|
||||
|
||||
|
||||
6
vendor/k8s.io/component-base/metrics/opts.go
generated
vendored
6
vendor/k8s.io/component-base/metrics/opts.go
generated
vendored
@@ -66,9 +66,15 @@ func BuildFQName(namespace, subsystem, name string) string {
|
||||
type StabilityLevel string
|
||||
|
||||
const (
|
||||
// INTERNAL metrics have no stability guarantees, as such, labels may
|
||||
// be arbitrarily added/removed and the metric may be deleted at any time.
|
||||
INTERNAL StabilityLevel = "INTERNAL"
|
||||
// ALPHA metrics have no stability guarantees, as such, labels may
|
||||
// be arbitrarily added/removed and the metric may be deleted at any time.
|
||||
ALPHA StabilityLevel = "ALPHA"
|
||||
// BETA metrics are governed by the deprecation policy outlined in by
|
||||
// the control plane metrics stability KEP.
|
||||
BETA StabilityLevel = "BETA"
|
||||
// STABLE metrics are guaranteed not be mutated and removal is governed by
|
||||
// the deprecation policy outlined in by the control plane metrics stability KEP.
|
||||
STABLE StabilityLevel = "STABLE"
|
||||
|
||||
53
vendor/k8s.io/component-base/metrics/prometheus/feature/metrics.go
generated
vendored
Normal file
53
vendor/k8s.io/component-base/metrics/prometheus/feature/metrics.go
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright 2022 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 feature
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
k8smetrics "k8s.io/component-base/metrics"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
)
|
||||
|
||||
var (
|
||||
// featureInfo is a Prometheus Gauge metrics used for recording the enablement of a k8s feature.
|
||||
featureInfo = k8smetrics.NewGaugeVec(
|
||||
&k8smetrics.GaugeOpts{
|
||||
Namespace: "kubernetes",
|
||||
Name: "feature_enabled",
|
||||
Help: "This metric records the data about the stage and enablement of a k8s feature.",
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
},
|
||||
[]string{"name", "stage"},
|
||||
)
|
||||
)
|
||||
|
||||
func init() {
|
||||
legacyregistry.MustRegister(featureInfo)
|
||||
}
|
||||
|
||||
func ResetFeatureInfoMetric() {
|
||||
featureInfo.Reset()
|
||||
}
|
||||
|
||||
func RecordFeatureInfo(ctx context.Context, name string, stage string, enabled bool) {
|
||||
value := 0.0
|
||||
if enabled {
|
||||
value = 1.0
|
||||
}
|
||||
featureInfo.WithContext(ctx).WithLabelValues(name, stage).Set(value)
|
||||
}
|
||||
76
vendor/k8s.io/component-base/metrics/prometheus/slis/metrics.go
generated
vendored
Normal file
76
vendor/k8s.io/component-base/metrics/prometheus/slis/metrics.go
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright 2022 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 slis
|
||||
|
||||
import (
|
||||
"context"
|
||||
k8smetrics "k8s.io/component-base/metrics"
|
||||
)
|
||||
|
||||
type HealthcheckStatus string
|
||||
|
||||
const (
|
||||
Success HealthcheckStatus = "success"
|
||||
Error HealthcheckStatus = "error"
|
||||
)
|
||||
|
||||
type HealthcheckType string
|
||||
|
||||
var (
|
||||
// healthcheck is a Prometheus Gauge metrics used for recording the results of a k8s healthcheck.
|
||||
healthcheck = k8smetrics.NewGaugeVec(
|
||||
&k8smetrics.GaugeOpts{
|
||||
Namespace: "kubernetes",
|
||||
Name: "healthcheck",
|
||||
Help: "This metric records the result of a single healthcheck.",
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
},
|
||||
[]string{"name", "type"},
|
||||
)
|
||||
|
||||
// healthchecksTotal is a Prometheus Counter metrics used for counting the results of a k8s healthcheck.
|
||||
healthchecksTotal = k8smetrics.NewCounterVec(
|
||||
&k8smetrics.CounterOpts{
|
||||
Namespace: "kubernetes",
|
||||
Name: "healthchecks_total",
|
||||
Help: "This metric records the results of all healthcheck.",
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
},
|
||||
[]string{"name", "type", "status"},
|
||||
)
|
||||
)
|
||||
|
||||
func Register(registry k8smetrics.KubeRegistry) {
|
||||
registry.Register(healthcheck)
|
||||
registry.Register(healthchecksTotal)
|
||||
}
|
||||
|
||||
func ResetHealthMetrics() {
|
||||
healthcheck.Reset()
|
||||
healthchecksTotal.Reset()
|
||||
}
|
||||
|
||||
func ObserveHealthcheck(ctx context.Context, name string, healthcheckType string, status HealthcheckStatus) error {
|
||||
if status == Success {
|
||||
healthcheck.WithContext(ctx).WithLabelValues(name, healthcheckType).Set(1)
|
||||
} else {
|
||||
healthcheck.WithContext(ctx).WithLabelValues(name, healthcheckType).Set(0)
|
||||
}
|
||||
|
||||
healthchecksTotal.WithContext(ctx).WithLabelValues(name, healthcheckType, string(status)).Inc()
|
||||
return nil
|
||||
}
|
||||
27
vendor/k8s.io/component-base/metrics/prometheus/slis/registry.go
generated
vendored
Normal file
27
vendor/k8s.io/component-base/metrics/prometheus/slis/registry.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2020 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 slis
|
||||
|
||||
import (
|
||||
"k8s.io/component-base/metrics"
|
||||
)
|
||||
|
||||
var (
|
||||
// Registry exposes the SLI registry so that additional SLIs can be
|
||||
// added on a per-component basis.
|
||||
Registry = metrics.NewKubeRegistry()
|
||||
)
|
||||
53
vendor/k8s.io/component-base/metrics/prometheus/slis/routes.go
generated
vendored
Normal file
53
vendor/k8s.io/component-base/metrics/prometheus/slis/routes.go
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright 2020 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 slis
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"k8s.io/component-base/metrics"
|
||||
)
|
||||
|
||||
var (
|
||||
installOnce = sync.Once{}
|
||||
installWithResetOnce = sync.Once{}
|
||||
)
|
||||
|
||||
type mux interface {
|
||||
Handle(path string, handler http.Handler)
|
||||
}
|
||||
|
||||
type SLIMetrics struct{}
|
||||
|
||||
// Install adds the DefaultMetrics handler
|
||||
func (s SLIMetrics) Install(m mux) {
|
||||
installOnce.Do(func() {
|
||||
Register(Registry)
|
||||
m.Handle("/metrics/slis", metrics.HandlerFor(Registry, metrics.HandlerOpts{}))
|
||||
})
|
||||
}
|
||||
|
||||
type SLIMetricsWithReset struct{}
|
||||
|
||||
// Install adds the DefaultMetrics handler
|
||||
func (s SLIMetricsWithReset) Install(m mux) {
|
||||
installWithResetOnce.Do(func() {
|
||||
Register(Registry)
|
||||
m.Handle("/metrics/slis", metrics.HandlerWithReset(Registry, metrics.HandlerOpts{}))
|
||||
})
|
||||
}
|
||||
49
vendor/k8s.io/component-base/metrics/prometheus/workqueue/metrics.go
generated
vendored
49
vendor/k8s.io/component-base/metrics/prometheus/workqueue/metrics.go
generated
vendored
@@ -39,34 +39,39 @@ const (
|
||||
|
||||
var (
|
||||
depth = k8smetrics.NewGaugeVec(&k8smetrics.GaugeOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: DepthKey,
|
||||
Help: "Current depth of workqueue",
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: DepthKey,
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
Help: "Current depth of workqueue",
|
||||
}, []string{"name"})
|
||||
|
||||
adds = k8smetrics.NewCounterVec(&k8smetrics.CounterOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: AddsKey,
|
||||
Help: "Total number of adds handled by workqueue",
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: AddsKey,
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
Help: "Total number of adds handled by workqueue",
|
||||
}, []string{"name"})
|
||||
|
||||
latency = k8smetrics.NewHistogramVec(&k8smetrics.HistogramOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: QueueLatencyKey,
|
||||
Help: "How long in seconds an item stays in workqueue before being requested.",
|
||||
Buckets: k8smetrics.ExponentialBuckets(10e-9, 10, 10),
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: QueueLatencyKey,
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
Help: "How long in seconds an item stays in workqueue before being requested.",
|
||||
Buckets: k8smetrics.ExponentialBuckets(10e-9, 10, 10),
|
||||
}, []string{"name"})
|
||||
|
||||
workDuration = k8smetrics.NewHistogramVec(&k8smetrics.HistogramOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: WorkDurationKey,
|
||||
Help: "How long in seconds processing an item from workqueue takes.",
|
||||
Buckets: k8smetrics.ExponentialBuckets(10e-9, 10, 10),
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: WorkDurationKey,
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
Help: "How long in seconds processing an item from workqueue takes.",
|
||||
Buckets: k8smetrics.ExponentialBuckets(10e-9, 10, 10),
|
||||
}, []string{"name"})
|
||||
|
||||
unfinished = k8smetrics.NewGaugeVec(&k8smetrics.GaugeOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: UnfinishedWorkKey,
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: UnfinishedWorkKey,
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
Help: "How many seconds of work has done that " +
|
||||
"is in progress and hasn't been observed by work_duration. Large " +
|
||||
"values indicate stuck threads. One can deduce the number of stuck " +
|
||||
@@ -74,16 +79,18 @@ var (
|
||||
}, []string{"name"})
|
||||
|
||||
longestRunningProcessor = k8smetrics.NewGaugeVec(&k8smetrics.GaugeOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: LongestRunningProcessorKey,
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: LongestRunningProcessorKey,
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
Help: "How many seconds has the longest running " +
|
||||
"processor for workqueue been running.",
|
||||
}, []string{"name"})
|
||||
|
||||
retries = k8smetrics.NewCounterVec(&k8smetrics.CounterOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: RetriesKey,
|
||||
Help: "Total number of retries handled by workqueue",
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: RetriesKey,
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
Help: "Total number of retries handled by workqueue",
|
||||
}, []string{"name"})
|
||||
|
||||
metrics = []k8smetrics.Registerable{
|
||||
|
||||
56
vendor/k8s.io/component-base/metrics/registry.go
generated
vendored
56
vendor/k8s.io/component-base/metrics/registry.go
generated
vendored
@@ -32,10 +32,35 @@ import (
|
||||
var (
|
||||
showHiddenOnce sync.Once
|
||||
disabledMetricsLock sync.RWMutex
|
||||
showHidden atomic.Value
|
||||
showHidden atomic.Bool
|
||||
registries []*kubeRegistry // stores all registries created by NewKubeRegistry()
|
||||
registriesLock sync.RWMutex
|
||||
disabledMetrics = map[string]struct{}{}
|
||||
|
||||
registeredMetrics = NewCounterVec(
|
||||
&CounterOpts{
|
||||
Name: "registered_metric_total",
|
||||
Help: "The count of registered metrics broken by stability level and deprecation version.",
|
||||
StabilityLevel: ALPHA,
|
||||
},
|
||||
[]string{"stability_level", "deprecated_version"},
|
||||
)
|
||||
|
||||
disabledMetricsTotal = NewCounter(
|
||||
&CounterOpts{
|
||||
Name: "disabled_metric_total",
|
||||
Help: "The count of disabled metrics.",
|
||||
StabilityLevel: ALPHA,
|
||||
},
|
||||
)
|
||||
|
||||
hiddenMetricsTotal = NewCounter(
|
||||
&CounterOpts{
|
||||
Name: "hidden_metric_total",
|
||||
Help: "The count of hidden metrics.",
|
||||
StabilityLevel: ALPHA,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
// shouldHide be used to check if a specific metric with deprecated version should be hidden
|
||||
@@ -67,6 +92,7 @@ func SetDisabledMetric(name string) {
|
||||
disabledMetricsLock.Lock()
|
||||
defer disabledMetricsLock.Unlock()
|
||||
disabledMetrics[name] = struct{}{}
|
||||
disabledMetricsTotal.Inc()
|
||||
}
|
||||
|
||||
// SetShowHidden will enable showing hidden metrics. This will no-opt
|
||||
@@ -87,7 +113,7 @@ func SetShowHidden() {
|
||||
// is enabled. While the primary usecase for this is internal (to determine
|
||||
// registration behavior) this can also be used to introspect
|
||||
func ShouldShowHidden() bool {
|
||||
return showHidden.Load() != nil && showHidden.Load().(bool)
|
||||
return showHidden.Load()
|
||||
}
|
||||
|
||||
// Registerable is an interface for a collector metric which we
|
||||
@@ -129,6 +155,12 @@ type KubeRegistry interface {
|
||||
// Reset invokes the Reset() function on all items in the registry
|
||||
// which are added as resettables.
|
||||
Reset()
|
||||
// RegisterMetaMetrics registers metrics about the number of registered metrics.
|
||||
RegisterMetaMetrics()
|
||||
// Registerer exposes the underlying prometheus registerer
|
||||
Registerer() prometheus.Registerer
|
||||
// Gatherer exposes the underlying prometheus gatherer
|
||||
Gatherer() prometheus.Gatherer
|
||||
}
|
||||
|
||||
// kubeRegistry is a wrapper around a prometheus registry-type object. Upon initialization
|
||||
@@ -160,6 +192,16 @@ func (kr *kubeRegistry) Register(c Registerable) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Registerer exposes the underlying prometheus.Registerer
|
||||
func (kr *kubeRegistry) Registerer() prometheus.Registerer {
|
||||
return kr.PromRegistry
|
||||
}
|
||||
|
||||
// Gatherer exposes the underlying prometheus.Gatherer
|
||||
func (kr *kubeRegistry) Gatherer() prometheus.Gatherer {
|
||||
return kr.PromRegistry
|
||||
}
|
||||
|
||||
// MustRegister works like Register but registers any number of
|
||||
// Collectors and panics upon the first registration that causes an
|
||||
// error.
|
||||
@@ -250,6 +292,7 @@ func (kr *kubeRegistry) trackHiddenCollector(c Registerable) {
|
||||
defer kr.hiddenCollectorsLock.Unlock()
|
||||
|
||||
kr.hiddenCollectors[c.FQName()] = c
|
||||
hiddenMetricsTotal.Inc()
|
||||
}
|
||||
|
||||
// trackStableCollectors stores all custom collectors.
|
||||
@@ -329,9 +372,14 @@ func newKubeRegistry(v apimachineryversion.Info) *kubeRegistry {
|
||||
return r
|
||||
}
|
||||
|
||||
// NewKubeRegistry creates a new vanilla Registry without any Collectors
|
||||
// pre-registered.
|
||||
// NewKubeRegistry creates a new vanilla Registry
|
||||
func NewKubeRegistry() KubeRegistry {
|
||||
r := newKubeRegistry(BuildVersion())
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *kubeRegistry) RegisterMetaMetrics() {
|
||||
r.MustRegister(registeredMetrics)
|
||||
r.MustRegister(disabledMetricsTotal)
|
||||
r.MustRegister(hiddenMetricsTotal)
|
||||
}
|
||||
|
||||
4
vendor/k8s.io/component-base/metrics/summary.go
generated
vendored
4
vendor/k8s.io/component-base/metrics/summary.go
generated
vendored
@@ -49,7 +49,7 @@ func NewSummary(opts *SummaryOpts) *Summary {
|
||||
|
||||
s := &Summary{
|
||||
SummaryOpts: opts,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
s.setPrometheusSummary(noopMetric{})
|
||||
s.lazyInit(s, BuildFQName(opts.Namespace, opts.Subsystem, opts.Name))
|
||||
@@ -118,7 +118,7 @@ func NewSummaryVec(opts *SummaryOpts, labels []string) *SummaryVec {
|
||||
v := &SummaryVec{
|
||||
SummaryOpts: opts,
|
||||
originalLabels: labels,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
v.lazyInit(v, fqName)
|
||||
return v
|
||||
|
||||
7
vendor/k8s.io/component-base/metrics/timing_histogram.go
generated
vendored
7
vendor/k8s.io/component-base/metrics/timing_histogram.go
generated
vendored
@@ -57,7 +57,7 @@ func NewTestableTimingHistogram(nowFunc func() time.Time, opts *TimingHistogramO
|
||||
h := &TimingHistogram{
|
||||
TimingHistogramOpts: opts,
|
||||
nowFunc: nowFunc,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
h.setPrometheusHistogram(noopMetric{})
|
||||
h.lazyInit(h, BuildFQName(opts.Namespace, opts.Subsystem, opts.Name))
|
||||
@@ -136,7 +136,7 @@ func NewTestableTimingHistogramVec(nowFunc func() time.Time, opts *TimingHistogr
|
||||
TimingHistogramOpts: opts,
|
||||
nowFunc: nowFunc,
|
||||
originalLabels: labels,
|
||||
lazyMetric: lazyMetric{},
|
||||
lazyMetric: lazyMetric{stabilityLevel: opts.StabilityLevel},
|
||||
}
|
||||
v.lazyInit(v, fqName)
|
||||
return v
|
||||
@@ -177,6 +177,9 @@ func (v *TimingHistogramVec) WithLabelValuesChecked(lvs ...string) (GaugeMetric,
|
||||
v.LabelValueAllowLists.ConstrainToAllowedList(v.originalLabels, lvs)
|
||||
}
|
||||
ops, err := v.TimingHistogramVec.GetMetricWithLabelValues(lvs...)
|
||||
if err != nil {
|
||||
return noop, err
|
||||
}
|
||||
return ops.(GaugeMetric), err
|
||||
}
|
||||
|
||||
|
||||
10
vendor/k8s.io/component-base/metrics/value.go
generated
vendored
10
vendor/k8s.io/component-base/metrics/value.go
generated
vendored
@@ -47,6 +47,16 @@ func NewLazyConstMetric(desc *Desc, valueType ValueType, value float64, labelVal
|
||||
return prometheus.MustNewConstMetric(desc.toPrometheusDesc(), valueType.toPromValueType(), value, labelValues...)
|
||||
}
|
||||
|
||||
// NewConstMetric is a helper of NewConstMetric.
|
||||
//
|
||||
// Note: If the metrics described by the desc is hidden, the metrics will not be created.
|
||||
func NewConstMetric(desc *Desc, valueType ValueType, value float64, labelValues ...string) (Metric, error) {
|
||||
if desc.IsHidden() {
|
||||
return nil, nil
|
||||
}
|
||||
return prometheus.NewConstMetric(desc.toPrometheusDesc(), valueType.toPromValueType(), value, labelValues...)
|
||||
}
|
||||
|
||||
// NewLazyMetricWithTimestamp is a helper of NewMetricWithTimestamp.
|
||||
//
|
||||
// Warning: the Metric 'm' must be the one created by NewLazyConstMetric(),
|
||||
|
||||
6
vendor/k8s.io/component-base/metrics/wrappers.go
generated
vendored
6
vendor/k8s.io/component-base/metrics/wrappers.go
generated
vendored
@@ -145,6 +145,12 @@ type Gatherer interface {
|
||||
prometheus.Gatherer
|
||||
}
|
||||
|
||||
// Registerer is the interface for the part of a registry in charge of registering
|
||||
// the collected metrics.
|
||||
type Registerer interface {
|
||||
prometheus.Registerer
|
||||
}
|
||||
|
||||
// GaugeFunc is a Gauge whose value is determined at collect time by calling a
|
||||
// provided function.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user