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

Function Test_counter_demandTracking

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

Source from the content-addressed store, hash-verified

299}
300
301func Test_counter_demandTracking(t *testing.T) {
302 c := newCounter("my_counter", noopLimiter, map[string]string{}, 15*time.Minute)
303
304 // Initially, demand should be 0
305 assert.Equal(t, 0, c.countSeriesDemand())
306
307 // Add some series
308 for i := 0; i < 50; i++ {
309 lbls := buildTestLabels([]string{"label"}, []string{fmt.Sprintf("value-%d", i)})
310 c.Inc(lbls, 1.0)
311 }
312
313 // Demand should now be approximately 50 (within HLL error)
314 demand := c.countSeriesDemand()
315 assert.Greater(t, demand, 40, "demand should be close to 50")
316 assert.Less(t, demand, 60, "demand should be close to 50")
317
318 // Active series should exactly match
319 assert.Equal(t, 50, c.countActiveSeries())
320}
321
322func Test_counter_demandVsActiveSeries(t *testing.T) {
323 limitReached := false

Callers

nothing calls this directly

Calls 7

newCounterFunction · 0.85
buildTestLabelsFunction · 0.85
countSeriesDemandMethod · 0.65
IncMethod · 0.65
countActiveSeriesMethod · 0.65
EqualMethod · 0.45
LessMethod · 0.45

Tested by

no test coverage detected