MCPcopy Create free account
hub / github.com/cortexproject/cortex / verifyClientMetricsHistogram

Function verifyClientMetricsHistogram

integration/kv_test.go:189–218  ·  view source on GitHub ↗
(t *testing.T, reg *prometheus.Registry, metricNameToVerify string, sampleCounts map[string]uint64)

Source from the content-addressed store, hash-verified

187}
188
189func verifyClientMetricsHistogram(t *testing.T, reg *prometheus.Registry, metricNameToVerify string, sampleCounts map[string]uint64) {
190 metrics, err := reg.Gather()
191 require.NoError(t, err)
192
193 var metricToVerify *dto.MetricFamily
194 for _, metric := range metrics {
195 if metric.GetName() != metricNameToVerify {
196 continue
197 }
198 metricToVerify = metric
199 break
200 }
201 require.NotNilf(t, metricToVerify, "Metric %s not found in registry", metricNameToVerify)
202 require.Equal(t, dto.MetricType_HISTOGRAM, metricToVerify.GetType())
203
204 getMetricOperation := func(labels []*dto.LabelPair) (string, error) {
205 for _, l := range labels {
206 if l.GetName() == "operation" {
207 return l.GetValue(), nil
208 }
209 }
210 return "", errors.New("no operation")
211 }
212
213 for _, metric := range metricToVerify.GetMetric() {
214 op, err := getMetricOperation(metric.Label)
215 require.NoErrorf(t, err, "No operation label found in metric %v", metric.String())
216 assert.Equal(t, sampleCounts[op], metric.GetHistogram().GetSampleCount(), op)
217 }
218}
219
220type stringCodec struct{}
221

Callers 2

TestKVListFunction · 0.85
TestKVDeleteFunction · 0.85

Calls 7

EqualMethod · 0.65
StringMethod · 0.65
GetNameMethod · 0.45
GetTypeMethod · 0.45
GetValueMethod · 0.45
GetMetricMethod · 0.45
GetHistogramMethod · 0.45

Tested by

no test coverage detected