@@ -35,14 +35,14 @@ var (
3535 "metric1" : metrics.Metric {Description : "metric1" },
3636 }
3737 initialPresetDefs = metrics.PresetDefs {
38- "preset1" : metrics.Preset {Description : "preset1" , Metrics : map [ string ] float64 {"metric1" : 1.0 }},
38+ "preset1" : metrics.Preset {Description : "preset1" , Metrics : metrics. MetricIntervals {"metric1" : 1.0 }},
3939 }
4040
4141 newMetricDefs = metrics.MetricDefs {
4242 "metric2" : metrics.Metric {Description : "metric2" },
4343 }
4444 newPresetDefs = metrics.PresetDefs {
45- "preset2" : metrics.Preset {Description : "preset2" , Metrics : map [ string ] float64 {"metric2" : 2.0 }},
45+ "preset2" : metrics.Preset {Description : "preset2" , Metrics : metrics. MetricIntervals {"metric2" : 2.0 }},
4646 }
4747)
4848
@@ -139,7 +139,7 @@ func TestReaper_LoadMetrics(t *testing.T) {
139139 t .Run ("updates metricDefs on success" , func (t * testing.T ) {
140140 defs := & metrics.Metrics {
141141 MetricDefs : metrics.MetricDefs {"m1" : {Description : "M1" }},
142- PresetDefs : metrics.PresetDefs {"p1" : {Description : "P1" , Metrics : map [ string ] float64 {"m1" : 1.0 }}},
142+ PresetDefs : metrics.PresetDefs {"p1" : {Description : "P1" , Metrics : metrics. MetricIntervals {"m1" : 1.0 }}},
143143 }
144144 r := NewReaper (ctx , & cmdopts.Options {
145145 MetricsReaderWriter : & testutil.MockMetricsReaderWriter {
@@ -197,8 +197,8 @@ func TestReaper_LoadMetrics(t *testing.T) {
197197 "m2" : {Description : "M2" },
198198 },
199199 PresetDefs : metrics.PresetDefs {
200- "preset1" : {Metrics : map [ string ] float64 {"m1" : 10.0 }},
201- "standby1" : {Metrics : map [ string ] float64 {"m2" : 20.0 }},
200+ "preset1" : {Metrics : metrics. MetricIntervals {"m1" : 10.0 }},
201+ "standby1" : {Metrics : metrics. MetricIntervals {"m2" : 20.0 }},
202202 },
203203 }
204204 r := NewReaper (ctx , & cmdopts.Options {
@@ -216,12 +216,12 @@ func TestReaper_LoadMetrics(t *testing.T) {
216216 assert .NoError (t , r .LoadMetrics ())
217217
218218 sc := r .monitoredSources [0 ]
219- assert .Equal (t , map [ string ] float64 {"m1" : 10.0 }, sc .Metrics )
220- assert .Equal (t , map [ string ] float64 {"m2" : 20.0 }, sc .MetricsStandby )
219+ assert .Equal (t , metrics. MetricIntervals {"m1" : 10.0 }, sc .Metrics )
220+ assert .Equal (t , metrics. MetricIntervals {"m2" : 20.0 }, sc .MetricsStandby )
221221 })
222222
223223 t .Run ("skips preset resolution for sources without presets" , func (t * testing.T ) {
224- customMetrics := map [ string ] float64 {"cpu" : 5.0 }
224+ customMetrics := metrics. MetricIntervals {"cpu" : 5.0 }
225225 defs := & metrics.Metrics {
226226 MetricDefs : metrics.MetricDefs {"cpu" : {Description : "CPU" }},
227227 PresetDefs : metrics.PresetDefs {},
@@ -249,7 +249,7 @@ func TestReaper_LoadMetrics(t *testing.T) {
249249 initialDefs := & metrics.Metrics {
250250 MetricDefs : metrics.MetricDefs {"test_metric" : {}},
251251 PresetDefs : metrics.PresetDefs {
252- "test_preset" : {Metrics : map [ string ] float64 {"test_metric" : 1 }},
252+ "test_preset" : {Metrics : metrics. MetricIntervals {"test_metric" : 1 }},
253253 },
254254 }
255255 src := sources.Source {
@@ -272,7 +272,7 @@ func TestReaper_LoadMetrics(t *testing.T) {
272272 })
273273 require .NoError (t , r .LoadSources (ctx ))
274274 require .NoError (t , r .LoadMetrics ())
275- assert .Equal (t , map [ string ] float64 {"test_metric" : 1 }, r .monitoredSources [0 ].Metrics )
275+ assert .Equal (t , metrics. MetricIntervals {"test_metric" : 1 }, r .monitoredSources [0 ].Metrics )
276276
277277 // Attach a mock connection so CloseResourcesForRemovedMonitoredDBs doesn't panic
278278 // when the custom_tags change triggers a full source restart.
@@ -288,14 +288,14 @@ func TestReaper_LoadMetrics(t *testing.T) {
288288 updatedDefs := & metrics.Metrics {
289289 MetricDefs : metrics.MetricDefs {"test_metric" : {}},
290290 PresetDefs : metrics.PresetDefs {
291- "test_preset" : {Metrics : map [ string ] float64 {"test_metric" : 2 }},
291+ "test_preset" : {Metrics : metrics. MetricIntervals {"test_metric" : 2 }},
292292 },
293293 }
294294 getMetricsFn = func () (* metrics.Metrics , error ) { return updatedDefs , nil }
295295
296296 require .NoError (t , r .LoadSources (ctx ))
297297 require .NoError (t , r .LoadMetrics ())
298- assert .Equal (t , map [ string ] float64 {"test_metric" : 2 }, r .monitoredSources [0 ].Metrics ,
298+ assert .Equal (t , metrics. MetricIntervals {"test_metric" : 2 }, r .monitoredSources [0 ].Metrics ,
299299 "preset interval should be updated after source config change triggered a restart" )
300300 })
301301}
0 commit comments