@@ -36,10 +36,6 @@ import (
3636type TestMetricsRecorder struct {
3737 t * testing.T
3838
39- // TODO: scale this persisted storage up with label key values.
40- intValues map [* estats.MetricDescriptor ]int64
41- floatValues map [* estats.MetricDescriptor ]float64
42-
4339 intCountCh * testutils.Channel
4440 floatCountCh * testutils.Channel
4541 intHistoCh * testutils.Channel
@@ -48,31 +44,15 @@ type TestMetricsRecorder struct {
4844}
4945
5046func NewTestMetricsRecorder (t * testing.T , metrics []string ) * TestMetricsRecorder {
51- tmr := & TestMetricsRecorder {
52- t : t ,
53- intValues : make (map [* estats.MetricDescriptor ]int64 ),
54- floatValues : make (map [* estats.MetricDescriptor ]float64 ),
47+ return & TestMetricsRecorder {
48+ t : t ,
5549
5650 intCountCh : testutils .NewChannelWithSize (10 ),
5751 floatCountCh : testutils .NewChannelWithSize (10 ),
5852 intHistoCh : testutils .NewChannelWithSize (10 ),
5953 floatHistoCh : testutils .NewChannelWithSize (10 ),
6054 intGaugeCh : testutils .NewChannelWithSize (10 ),
6155 }
62-
63- for _ , metric := range metrics {
64- desc := estats .DescriptorForMetric (estats .Metric (metric ))
65- switch desc .Type {
66- case estats .MetricTypeIntCount :
67- case estats .MetricTypeIntHisto :
68- case estats .MetricTypeIntGauge :
69- tmr .intValues [desc ] = 0
70- case estats .MetricTypeFloatCount :
71- case estats .MetricTypeFloatHisto :
72- tmr .floatValues [desc ] = 0
73- }
74- }
75- return tmr
7656}
7757
7858type MetricsData struct {
@@ -105,8 +85,6 @@ func (r *TestMetricsRecorder) RecordInt64Count(handle *estats.Int64CountHandle,
10585 LabelKeys : append (handle .Labels , handle .OptionalLabels ... ),
10686 LabelVals : labels ,
10787 })
108-
109- r .intValues [(* estats .MetricDescriptor )(handle )] += incr
11088}
11189
11290func (r * TestMetricsRecorder ) WaitForFloat64Count (ctx context.Context , metricsDataWant MetricsData ) {
@@ -127,8 +105,6 @@ func (r *TestMetricsRecorder) RecordFloat64Count(handle *estats.Float64CountHand
127105 LabelKeys : append (handle .Labels , handle .OptionalLabels ... ),
128106 LabelVals : labels ,
129107 })
130-
131- r .floatValues [(* estats .MetricDescriptor )(handle )] += incr
132108}
133109
134110func (r * TestMetricsRecorder ) WaitForInt64Histo (ctx context.Context , metricsDataWant MetricsData ) {
@@ -149,8 +125,6 @@ func (r *TestMetricsRecorder) RecordInt64Histo(handle *estats.Int64HistoHandle,
149125 LabelKeys : append (handle .Labels , handle .OptionalLabels ... ),
150126 LabelVals : labels ,
151127 })
152-
153- r .intValues [(* estats .MetricDescriptor )(handle )] += incr
154128}
155129
156130func (r * TestMetricsRecorder ) WaitForFloat64Histo (ctx context.Context , metricsDataWant MetricsData ) {
@@ -171,7 +145,6 @@ func (r *TestMetricsRecorder) RecordFloat64Histo(handle *estats.Float64HistoHand
171145 LabelKeys : append (handle .Labels , handle .OptionalLabels ... ),
172146 LabelVals : labels ,
173147 })
174- r .floatValues [(* estats .MetricDescriptor )(handle )] += incr
175148}
176149
177150func (r * TestMetricsRecorder ) WaitForInt64Gauge (ctx context.Context , metricsDataWant MetricsData ) {
@@ -192,8 +165,6 @@ func (r *TestMetricsRecorder) RecordInt64Gauge(handle *estats.Int64GaugeHandle,
192165 LabelKeys : append (handle .Labels , handle .OptionalLabels ... ),
193166 LabelVals : labels ,
194167 })
195-
196- r .intValues [(* estats .MetricDescriptor )(handle )] = incr
197168}
198169
199170// To implement a stats.Handler, which allows it to be set as a dial option:
0 commit comments