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

Function TestGaugeDifferentLabels

modules/generator/registry/gauge_test.go:52–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestGaugeDifferentLabels(t *testing.T) {
53 var seriesAdded int
54 lifecycler := &mockLimiter{
55 onAddFunc: func(hash uint64, _ uint32, lbls labels.Labels) (labels.Labels, uint64) {
56 seriesAdded++
57 return lbls, hash
58 },
59 }
60
61 c := newGauge("my_gauge", lifecycler, map[string]string{}, 15*time.Minute)
62
63 c.Inc(buildTestLabels([]string{"label"}, []string{"value-1"}), 1.0)
64 c.Inc(buildTestLabels([]string{"another_label"}, []string{"another_value"}), 2.0)
65
66 assert.Equal(t, 2, seriesAdded)
67
68 collectionTimeMs := time.Now().UnixMilli()
69 expectedSamples := []sample{
70 newSample(map[string]string{"__name__": "my_gauge", "label": "value-1"}, collectionTimeMs, 1),
71 newSample(map[string]string{"__name__": "my_gauge", "another_label": "another_value"}, collectionTimeMs, 2),
72 }
73 collectMetricAndAssert(t, c, collectionTimeMs, 2, expectedSamples, nil)
74}
75
76func Test_gaugeSet(t *testing.T) {
77 var seriesAdded int

Callers

nothing calls this directly

Calls 7

newGaugeFunction · 0.85
buildTestLabelsFunction · 0.85
newSampleFunction · 0.85
collectMetricAndAssertFunction · 0.85
IncMethod · 0.65
NowMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected