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

Function Test_histogram_demandTracking

modules/generator/registry/histogram_test.go:441–462  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

439}
440
441func Test_histogram_demandTracking(t *testing.T) {
442 h := newHistogram("my_histogram", []float64{1.0, 2.0}, noopLimiter, "", nil, 15*time.Minute)
443
444 // Initially, demand should be 0
445 assert.Equal(t, 0, h.countSeriesDemand())
446
447 // Add some histogram series (each histogram creates multiple series)
448 for i := 0; i < 20; i++ {
449 lbls := buildTestLabels([]string{"label"}, []string{fmt.Sprintf("value-%d", i)})
450 h.ObserveWithExemplar(lbls, 1.5, "", 1.0)
451 }
452
453 // Demand should be approximately 20 histogram series * 5 (sum, count, 3 buckets) = 100 total series
454 // Within HLL error
455 demand := h.countSeriesDemand()
456 assert.Greater(t, demand, 80, "demand should be close to 100")
457 assert.Less(t, demand, 120, "demand should be close to 100")
458
459 // Active series should exactly match 20 * 5
460 expectedActive := 20 * int(h.activeSeriesPerHistogramSerie())
461 assert.Equal(t, expectedActive, h.countActiveSeries())
462}
463
464func Test_histogram_activeSeriesPerHistogramSerie(t *testing.T) {
465 // Test with 2 buckets (creates: sum, count, bucket1, bucket2, +Inf)

Callers

nothing calls this directly

Calls 8

newHistogramFunction · 0.85
buildTestLabelsFunction · 0.85
countSeriesDemandMethod · 0.65
ObserveWithExemplarMethod · 0.65
countActiveSeriesMethod · 0.65
EqualMethod · 0.45
LessMethod · 0.45

Tested by

no test coverage detected