in sample-apps/prometheus-sample-app/metrics/metrics_collector.go [104:117]
func (mc *metricCollector) registerCounter(count int) {
for idx := 0; idx < count; idx++ {
namespace := "test"
counter := prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Name: fmt.Sprintf("counter%v", idx),
Help: "This is my counter",
},
append([]string{"datapoint_id"}, mc.labelKeys...))
promRegistry.MustRegister(counter)
mc.counters = append(mc.counters, counter)
}
}