(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func TestCardinalityControlAdd(t *testing.T) { |
| 139 | t.Parallel() |
| 140 | |
| 141 | registry := metrics.NewRegistry() |
| 142 | m1, err := registry.NewMetric("metric1", metrics.Counter) |
| 143 | require.NoError(t, err) |
| 144 | |
| 145 | m2, err := registry.NewMetric("metric2", metrics.Counter) |
| 146 | require.NoError(t, err) |
| 147 | |
| 148 | tags := registry.RootTagSet().With("k", "v") |
| 149 | |
| 150 | cc := newCardinalityControl() |
| 151 | // the first iteration adds two new time series |
| 152 | // the second does not change the count |
| 153 | // because the time series have been already seen before |
| 154 | for range 2 { |
| 155 | cc.Add(metrics.TimeSeries{ |
| 156 | Metric: m1, |
| 157 | Tags: tags, |
| 158 | }) |
| 159 | cc.Add(metrics.TimeSeries{ |
| 160 | Metric: m2, |
| 161 | Tags: tags, |
| 162 | }) |
| 163 | assert.Equal(t, 2, len(cc.seen)) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | func TestCardinalityControlLimitHit(t *testing.T) { |
| 168 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…