MCPcopy
hub / github.com/grafana/tempo / TestTestRegistry_histogram

Function TestTestRegistry_histogram

modules/generator/registry/test_test.go:28–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestTestRegistry_histogram(t *testing.T) {
29 testRegistry := NewTestRegistry()
30
31 histogram := testRegistry.NewHistogram("histogram", []float64{1.0, 2.0}, HistogramModeClassic)
32
33 labelValues := buildTestLabels([]string{"foo", "bar"}, []string{"foo-value", "bar-value"})
34 histogram.ObserveWithExemplar(labelValues, 1.0, "", 1.0)
35 histogram.ObserveWithExemplar(labelValues, 2.0, "", 1.0)
36 histogram.ObserveWithExemplar(labelValues, 2.5, "", 1.0)
37
38 lbls := labels.FromMap(map[string]string{
39 "foo": "foo-value",
40 "bar": "bar-value",
41 })
42 assert.Equal(t, 1.0, testRegistry.Query("histogram_bucket", withLe(lbls, 1.0)))
43 assert.Equal(t, 2.0, testRegistry.Query("histogram_bucket", withLe(lbls, 2.0)))
44 assert.Equal(t, 3.0, testRegistry.Query("histogram_bucket", withLe(lbls, math.Inf(1))))
45 assert.Equal(t, 3.0, testRegistry.Query("histogram_count", lbls))
46 assert.Equal(t, 5.5, testRegistry.Query("histogram_sum", lbls))
47}

Callers

nothing calls this directly

Calls 7

NewHistogramMethod · 0.95
ObserveWithExemplarMethod · 0.95
QueryMethod · 0.95
NewTestRegistryFunction · 0.85
buildTestLabelsFunction · 0.85
withLeFunction · 0.70
EqualMethod · 0.45

Tested by

no test coverage detected