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"
@@ -249,6 +250,13 @@ func (v *CounterVec) Reset() {
249
250
v .CounterVec .Reset ()
250
251
}
251
252
253
+ // ResetLabelAllowLists resets the label allow list for the CounterVec.
254
+ // NOTE: This should only be used in test.
255
+ func (v * CounterVec ) ResetLabelAllowLists () {
256
+ v .initializeLabelAllowListsOnce = sync.Once {}
257
+ v .LabelValueAllowLists = nil
258
+ }
259
+
252
260
// WithContext returns wrapped CounterVec with context
253
261
func (v * CounterVec ) WithContext (ctx context.Context ) * CounterVecWithContext {
254
262
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"
@@ -202,6 +203,13 @@ func (v *HistogramVec) Reset() {
202
203
v .HistogramVec .Reset ()
203
204
}
204
205
206
+ // ResetLabelAllowLists resets the label allow list for the HistogramVec.
207
+ // NOTE: This should only be used in test.
208
+ func (v * HistogramVec ) ResetLabelAllowLists () {
209
+ v .initializeLabelAllowListsOnce = sync.Once {}
210
+ v .LabelValueAllowLists = nil
211
+ }
212
+
205
213
// WithContext returns wrapped HistogramVec with context
206
214
func (v * HistogramVec ) WithContext (ctx context.Context ) * HistogramVecWithContext {
207
215
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