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

Function Test_counter_demandDecay

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

Source from the content-addressed store, hash-verified

361}
362
363func Test_counter_demandDecay(t *testing.T) {
364 c := newCounter("my_counter", noopLimiter, map[string]string{}, 15*time.Minute)
365
366 // Add series
367 for i := 0; i < 40; i++ {
368 lbls := buildTestLabels([]string{"label"}, []string{fmt.Sprintf("value-%d", i)})
369 c.Inc(lbls, 1.0)
370 }
371
372 initialDemand := c.countSeriesDemand()
373 assert.Greater(t, initialDemand, 0)
374
375 // Advance the cardinality tracker enough times to clear the window
376 for i := 0; i < 5; i++ {
377 c.removeStaleSeries(time.Now().UnixMilli())
378 }
379
380 // Demand should have decreased or be zero
381 finalDemand := c.countSeriesDemand()
382 assert.LessOrEqual(t, finalDemand, initialDemand/2, "demand should significantly decay")
383}
384
385func Test_counter_onUpdate(t *testing.T) {
386 var seriesUpdated int

Callers

nothing calls this directly

Calls 6

newCounterFunction · 0.85
buildTestLabelsFunction · 0.85
IncMethod · 0.65
countSeriesDemandMethod · 0.65
removeStaleSeriesMethod · 0.65
NowMethod · 0.65

Tested by

no test coverage detected