mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #128321 from yongruilin/reset-label-allow-list
feat(metrics): Add method to reset label allow lists
This commit is contained in:
commit
36081ff24f
@ -18,6 +18,7 @@ package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -273,6 +274,13 @@ func (v *CounterVec) Reset() {
|
||||
v.CounterVec.Reset()
|
||||
}
|
||||
|
||||
// ResetLabelAllowLists resets the label allow list for the CounterVec.
|
||||
// NOTE: This should only be used in test.
|
||||
func (v *CounterVec) ResetLabelAllowLists() {
|
||||
v.initializeLabelAllowListsOnce = sync.Once{}
|
||||
v.LabelValueAllowLists = nil
|
||||
}
|
||||
|
||||
// WithContext returns wrapped CounterVec with context
|
||||
func (v *CounterVec) WithContext(ctx context.Context) *CounterVecWithContext {
|
||||
return &CounterVecWithContext{
|
||||
|
@ -18,6 +18,7 @@ package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -239,6 +240,13 @@ func (v *GaugeVec) Reset() {
|
||||
v.GaugeVec.Reset()
|
||||
}
|
||||
|
||||
// ResetLabelAllowLists resets the label allow list for the GaugeVec.
|
||||
// NOTE: This should only be used in test.
|
||||
func (v *GaugeVec) ResetLabelAllowLists() {
|
||||
v.initializeLabelAllowListsOnce = sync.Once{}
|
||||
v.LabelValueAllowLists = nil
|
||||
}
|
||||
|
||||
func newGaugeFunc(opts *GaugeOpts, function func() float64, v semver.Version) GaugeFunc {
|
||||
g := NewGauge(opts)
|
||||
|
||||
|
@ -18,6 +18,7 @@ package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -241,6 +242,13 @@ func (v *HistogramVec) Reset() {
|
||||
v.HistogramVec.Reset()
|
||||
}
|
||||
|
||||
// ResetLabelAllowLists resets the label allow list for the HistogramVec.
|
||||
// NOTE: This should only be used in test.
|
||||
func (v *HistogramVec) ResetLabelAllowLists() {
|
||||
v.initializeLabelAllowListsOnce = sync.Once{}
|
||||
v.LabelValueAllowLists = nil
|
||||
}
|
||||
|
||||
// WithContext returns wrapped HistogramVec with context
|
||||
func (v *HistogramVec) WithContext(ctx context.Context) *HistogramVecWithContext {
|
||||
return &HistogramVecWithContext{
|
||||
|
@ -18,6 +18,7 @@ package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -214,6 +215,13 @@ func (v *SummaryVec) Reset() {
|
||||
v.SummaryVec.Reset()
|
||||
}
|
||||
|
||||
// ResetLabelAllowLists resets the label allow list for the SummaryVec.
|
||||
// NOTE: This should only be used in test.
|
||||
func (v *SummaryVec) ResetLabelAllowLists() {
|
||||
v.initializeLabelAllowListsOnce = sync.Once{}
|
||||
v.LabelValueAllowLists = nil
|
||||
}
|
||||
|
||||
// WithContext returns wrapped SummaryVec with context
|
||||
func (v *SummaryVec) WithContext(ctx context.Context) *SummaryVecWithContext {
|
||||
return &SummaryVecWithContext{
|
||||
|
@ -18,6 +18,7 @@ package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
@ -267,6 +268,13 @@ func (v *TimingHistogramVec) Reset() {
|
||||
v.TimingHistogramVec.Reset()
|
||||
}
|
||||
|
||||
// ResetLabelAllowLists resets the label allow list for the TimingHistogramVec.
|
||||
// NOTE: This should only be used in test.
|
||||
func (v *TimingHistogramVec) ResetLabelAllowLists() {
|
||||
v.initializeLabelAllowListsOnce = sync.Once{}
|
||||
v.LabelValueAllowLists = nil
|
||||
}
|
||||
|
||||
// WithContext returns wrapped TimingHistogramVec with context
|
||||
func (v *TimingHistogramVec) InterfaceWithContext(ctx context.Context) GaugeVecMetric {
|
||||
return &TimingHistogramVecWithContext{
|
||||
|
Loading…
Reference in New Issue
Block a user