(t *testing.T)
| 299 | } |
| 300 | |
| 301 | func 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 | |
| 322 | func Test_counter_demandVsActiveSeries(t *testing.T) { |
| 323 | limitReached := false |
nothing calls this directly
no test coverage detected