()
| 1220 | } |
| 1221 | |
| 1222 | func setupTestMetrics() *testMetrics { |
| 1223 | const numUsers = 5 |
| 1224 | const cardinality = 5 |
| 1225 | |
| 1226 | tm := newTestMetrics() |
| 1227 | |
| 1228 | for userID := 1; userID <= numUsers; userID++ { |
| 1229 | reg := prometheus.NewRegistry() |
| 1230 | |
| 1231 | labelNames := []string{"label_one", "label_two"} |
| 1232 | |
| 1233 | g := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{Name: "test_gauge"}, labelNames) |
| 1234 | for i := 0; i < cardinality; i++ { |
| 1235 | g.WithLabelValues("a", strconv.Itoa(i)).Set(float64(userID)) |
| 1236 | } |
| 1237 | |
| 1238 | c := promauto.With(reg).NewCounterVec(prometheus.CounterOpts{Name: "test_counter"}, labelNames) |
| 1239 | for i := 0; i < cardinality; i++ { |
| 1240 | c.WithLabelValues("a", strconv.Itoa(i)).Add(float64(userID)) |
| 1241 | } |
| 1242 | |
| 1243 | h := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{Name: "test_histogram", Buckets: []float64{1, 3, 5}}, labelNames) |
| 1244 | for i := 0; i < cardinality; i++ { |
| 1245 | h.WithLabelValues("a", strconv.Itoa(i)).Observe(float64(userID)) |
| 1246 | } |
| 1247 | |
| 1248 | s := promauto.With(reg).NewSummaryVec(prometheus.SummaryOpts{Name: "test_summary"}, labelNames) |
| 1249 | for i := 0; i < cardinality; i++ { |
| 1250 | s.WithLabelValues("a", strconv.Itoa(i)).Observe(float64(userID)) |
| 1251 | } |
| 1252 | |
| 1253 | tm.regs.AddTenantRegistry(strconv.Itoa(userID), reg) |
| 1254 | } |
| 1255 | return tm |
| 1256 | } |
| 1257 | |
| 1258 | type testMetrics struct { |
| 1259 | regs *TenantRegistries |
no test coverage detected