MCPcopy
hub / github.com/grafana/k6 / TestCardinalityControlAdd

Function TestCardinalityControlAdd

internal/metrics/engine/ingester_test.go:138–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func 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
167func TestCardinalityControlLimitHit(t *testing.T) {
168 t.Parallel()

Callers

nothing calls this directly

Calls 7

NewMetricMethod · 0.95
RootTagSetMethod · 0.95
NewRegistryFunction · 0.92
newCardinalityControlFunction · 0.85
WithMethod · 0.80
EqualMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…