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

Function Test_gauge_demandTracking

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

newGaugeFunction · 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