MCPcopy
hub / github.com/grafana/dskit / TestMaxGauges

Function TestMaxGauges

metrics/tenant_registries_test.go:71–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestMaxGauges(t *testing.T) {
72 type testcase struct {
73 exp float64
74 mf MetricFamilyMap
75 }
76
77 for _, tc := range []testcase{
78 {exp: math.NaN(), mf: MetricFamilyMap{}},
79 {exp: math.NaN(), mf: MetricFamilyMap{"metric": nil}},
80 {exp: math.NaN(), mf: MetricFamilyMap{"metric": &dto.MetricFamily{Metric: nil}}},
81 {exp: math.NaN(), mf: MetricFamilyMap{"metric": &dto.MetricFamily{Metric: []*dto.Metric{{Gauge: &dto.Gauge{}}}}}},
82 {exp: 12345.6789, mf: MetricFamilyMap{"metric": &dto.MetricFamily{Metric: []*dto.Metric{{Gauge: &dto.Gauge{Value: proto.Float64(12345.6789)}}}}}},
83 {exp: 7890.12345, mf: MetricFamilyMap{"metric": &dto.MetricFamily{Metric: []*dto.Metric{
84 {Gauge: &dto.Gauge{Value: proto.Float64(1234.56789)}},
85 {Gauge: &dto.Gauge{Value: proto.Float64(7890.12345)}},
86 }}}},
87 } {
88 checkFloats(t, tc.mf.MaxGauges("metric"), tc.exp)
89 }
90}
91
92func TestCounterValue(t *testing.T) {
93 require.Equal(t, float64(0), counterValue(nil))

Callers

nothing calls this directly

Calls 2

checkFloatsFunction · 0.85
MaxGaugesMethod · 0.80

Tested by

no test coverage detected