@@ -24,10 +24,16 @@ import (
24
24
promext "k8s.io/component-base/metrics/prometheusextension"
25
25
)
26
26
27
- // TimingHistogram is our internal representation for our wrapping struct around timing
28
- // histograms. It implements both kubeCollector and GaugeMetric
29
- type TimingHistogram struct {
27
+ // PrometheusTimingHistogram is the abstraction of the underlying histogram
28
+ // that we want to promote from the wrapper.
29
+ type PrometheusTimingHistogram interface {
30
30
GaugeMetric
31
+ }
32
+
33
+ // TimingHistogram is our internal representation for our wrapping struct around
34
+ // timing histograms. It implements both kubeCollector and GaugeMetric
35
+ type TimingHistogram struct {
36
+ PrometheusTimingHistogram
31
37
* TimingHistogramOpts
32
38
nowFunc func () time.Time
33
39
lazyMetric
@@ -60,7 +66,7 @@ func NewTestableTimingHistogram(nowFunc func() time.Time, opts *TimingHistogramO
60
66
61
67
// setPrometheusHistogram sets the underlying KubeGauge object, i.e. the thing that does the measurement.
62
68
func (h * TimingHistogram ) setPrometheusHistogram (histogram promext.TimingHistogram ) {
63
- h .GaugeMetric = histogram
69
+ h .PrometheusTimingHistogram = histogram
64
70
h .initSelfCollection (histogram )
65
71
}
66
72
@@ -90,7 +96,7 @@ func (h *TimingHistogram) initializeDeprecatedMetric() {
90
96
91
97
// WithContext allows the normal TimingHistogram metric to pass in context. The context is no-op now.
92
98
func (h * TimingHistogram ) WithContext (ctx context.Context ) GaugeMetric {
93
- return h .GaugeMetric
99
+ return h .PrometheusTimingHistogram
94
100
}
95
101
96
102
// TimingHistogramVec is the internal representation of our wrapping struct around prometheus
@@ -151,20 +157,20 @@ func (v *TimingHistogramVec) initializeDeprecatedMetric() {
151
157
v .initializeMetric ()
152
158
}
153
159
154
- // WithLabelValuesChecked, if called on a hidden vector,
155
- // will return a noop gauge and a nil error.
156
- // If called before this vector has been registered in
160
+ // WithLabelValuesChecked, if called before this vector has been registered in
157
161
// at least one registry, will return a noop gauge and
158
162
// an error that passes ErrIsNotRegistered.
163
+ // If called on a hidden vector,
164
+ // will return a noop gauge and a nil error.
159
165
// If called with a syntactic problem in the labels, will
160
166
// return a noop gauge and an error about the labels.
161
167
// If none of the above apply, this method will return
162
168
// the appropriate vector member and a nil error.
163
169
func (v * TimingHistogramVec ) WithLabelValuesChecked (lvs ... string ) (GaugeMetric , error ) {
164
- if v .IsHidden () {
165
- return noop , nil
166
- }
167
170
if ! v .IsCreated () {
171
+ if v .IsHidden () {
172
+ return noop , nil
173
+ }
168
174
return noop , errNotRegistered
169
175
}
170
176
if v .LabelValueAllowLists != nil {
@@ -187,20 +193,20 @@ func (v *TimingHistogramVec) WithLabelValues(lvs ...string) GaugeMetric {
187
193
panic (err )
188
194
}
189
195
190
- // WithChecked, if called on a hidden vector,
191
- // will return a noop gauge and a nil error.
192
- // If called before this vector has been registered in
196
+ // WithChecked, if called before this vector has been registered in
193
197
// at least one registry, will return a noop gauge and
194
198
// an error that passes ErrIsNotRegistered.
199
+ // If called on a hidden vector,
200
+ // will return a noop gauge and a nil error.
195
201
// If called with a syntactic problem in the labels, will
196
202
// return a noop gauge and an error about the labels.
197
203
// If none of the above apply, this method will return
198
204
// the appropriate vector member and a nil error.
199
205
func (v * TimingHistogramVec ) WithChecked (labels map [string ]string ) (GaugeMetric , error ) {
200
- if v .IsHidden () {
201
- return noop , nil
202
- }
203
206
if ! v .IsCreated () {
207
+ if v .IsHidden () {
208
+ return noop , nil
209
+ }
204
210
return noop , errNotRegistered
205
211
}
206
212
if v .LabelValueAllowLists != nil {
0 commit comments