(t *testing.T)
| 439 | } |
| 440 | |
| 441 | func 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 | |
| 464 | func Test_histogram_activeSeriesPerHistogramSerie(t *testing.T) { |
| 465 | // Test with 2 buckets (creates: sum, count, bucket1, bucket2, +Inf) |
nothing calls this directly
no test coverage detected