File tree Expand file tree Collapse file tree 5 files changed +40
-0
lines changed
staging/src/k8s.io/component-base/metrics Expand file tree Collapse file tree 5 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package metrics
18
18
19
19
import (
20
20
"context"
21
+ "sync"
21
22
22
23
"github.com/blang/semver/v4"
23
24
"github.com/prometheus/client_golang/prometheus"
@@ -273,6 +274,13 @@ func (v *CounterVec) Reset() {
273
274
v .CounterVec .Reset ()
274
275
}
275
276
277
+ // ResetLabelAllowLists resets the label allow list for the CounterVec.
278
+ // NOTE: This should only be used in test.
279
+ func (v * CounterVec ) ResetLabelAllowLists () {
280
+ v .initializeLabelAllowListsOnce = sync.Once {}
281
+ v .LabelValueAllowLists = nil
282
+ }
283
+
276
284
// WithContext returns wrapped CounterVec with context
277
285
func (v * CounterVec ) WithContext (ctx context.Context ) * CounterVecWithContext {
278
286
return & CounterVecWithContext {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package metrics
18
18
19
19
import (
20
20
"context"
21
+ "sync"
21
22
22
23
"github.com/blang/semver/v4"
23
24
"github.com/prometheus/client_golang/prometheus"
@@ -239,6 +240,13 @@ func (v *GaugeVec) Reset() {
239
240
v .GaugeVec .Reset ()
240
241
}
241
242
243
+ // ResetLabelAllowLists resets the label allow list for the GaugeVec.
244
+ // NOTE: This should only be used in test.
245
+ func (v * GaugeVec ) ResetLabelAllowLists () {
246
+ v .initializeLabelAllowListsOnce = sync.Once {}
247
+ v .LabelValueAllowLists = nil
248
+ }
249
+
242
250
func newGaugeFunc (opts * GaugeOpts , function func () float64 , v semver.Version ) GaugeFunc {
243
251
g := NewGauge (opts )
244
252
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package metrics
18
18
19
19
import (
20
20
"context"
21
+ "sync"
21
22
22
23
"github.com/blang/semver/v4"
23
24
"github.com/prometheus/client_golang/prometheus"
@@ -241,6 +242,13 @@ func (v *HistogramVec) Reset() {
241
242
v .HistogramVec .Reset ()
242
243
}
243
244
245
+ // ResetLabelAllowLists resets the label allow list for the HistogramVec.
246
+ // NOTE: This should only be used in test.
247
+ func (v * HistogramVec ) ResetLabelAllowLists () {
248
+ v .initializeLabelAllowListsOnce = sync.Once {}
249
+ v .LabelValueAllowLists = nil
250
+ }
251
+
244
252
// WithContext returns wrapped HistogramVec with context
245
253
func (v * HistogramVec ) WithContext (ctx context.Context ) * HistogramVecWithContext {
246
254
return & HistogramVecWithContext {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package metrics
18
18
19
19
import (
20
20
"context"
21
+ "sync"
21
22
22
23
"github.com/blang/semver/v4"
23
24
"github.com/prometheus/client_golang/prometheus"
@@ -214,6 +215,13 @@ func (v *SummaryVec) Reset() {
214
215
v .SummaryVec .Reset ()
215
216
}
216
217
218
+ // ResetLabelAllowLists resets the label allow list for the SummaryVec.
219
+ // NOTE: This should only be used in test.
220
+ func (v * SummaryVec ) ResetLabelAllowLists () {
221
+ v .initializeLabelAllowListsOnce = sync.Once {}
222
+ v .LabelValueAllowLists = nil
223
+ }
224
+
217
225
// WithContext returns wrapped SummaryVec with context
218
226
func (v * SummaryVec ) WithContext (ctx context.Context ) * SummaryVecWithContext {
219
227
return & SummaryVecWithContext {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package metrics
18
18
19
19
import (
20
20
"context"
21
+ "sync"
21
22
"time"
22
23
23
24
"github.com/blang/semver/v4"
@@ -267,6 +268,13 @@ func (v *TimingHistogramVec) Reset() {
267
268
v .TimingHistogramVec .Reset ()
268
269
}
269
270
271
+ // ResetLabelAllowLists resets the label allow list for the TimingHistogramVec.
272
+ // NOTE: This should only be used in test.
273
+ func (v * TimingHistogramVec ) ResetLabelAllowLists () {
274
+ v .initializeLabelAllowListsOnce = sync.Once {}
275
+ v .LabelValueAllowLists = nil
276
+ }
277
+
270
278
// WithContext returns wrapped TimingHistogramVec with context
271
279
func (v * TimingHistogramVec ) InterfaceWithContext (ctx context.Context ) GaugeVecMetric {
272
280
return & TimingHistogramVecWithContext {
You can’t perform that action at this time.
0 commit comments