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

Function Test_counter_externalLabels

modules/generator/registry/counter_test.go:180–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func Test_counter_externalLabels(t *testing.T) {
181 c := newCounter("my_counter", noopLimiter, map[string]string{"external_label": "external_value"}, 15*time.Minute)
182
183 c.Inc(buildTestLabels([]string{"label"}, []string{"value-1"}), 1.0)
184 c.Inc(buildTestLabels([]string{"label"}, []string{"value-2"}), 2.0)
185
186 collectionTimeMs := time.Now().UnixMilli()
187 endOfLastMinuteMs := getEndOfLastMinuteMs(collectionTimeMs)
188 expectedSamples := []sample{
189 newSample(map[string]string{"__name__": "my_counter", "label": "value-1", "external_label": "external_value"}, endOfLastMinuteMs, 0),
190 newSample(map[string]string{"__name__": "my_counter", "label": "value-1", "external_label": "external_value"}, collectionTimeMs, 1),
191 newSample(map[string]string{"__name__": "my_counter", "label": "value-2", "external_label": "external_value"}, endOfLastMinuteMs, 0),
192 newSample(map[string]string{"__name__": "my_counter", "label": "value-2", "external_label": "external_value"}, collectionTimeMs, 2),
193 }
194 collectMetricAndAssert(t, c, collectionTimeMs, 2, expectedSamples, nil)
195}
196
197func Test_counter_concurrencyDataRace(t *testing.T) {
198 c := newCounter("my_counter", noopLimiter, map[string]string{}, 15*time.Minute)

Callers

nothing calls this directly

Calls 7

newCounterFunction · 0.85
buildTestLabelsFunction · 0.85
getEndOfLastMinuteMsFunction · 0.85
newSampleFunction · 0.85
collectMetricAndAssertFunction · 0.85
IncMethod · 0.65
NowMethod · 0.65

Tested by

no test coverage detected