diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index e6d6bec..f91797c 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -19,6 +19,7 @@ import ( "hash" "hash/fnv" "sort" + "strings" "time" "github.com/prometheus/client_golang/prometheus" @@ -165,6 +166,15 @@ func (r *Registry) GetCounter(metricName string, labels prometheus.Labels, help return nil, fmt.Errorf("metric with name %s is already registered", metricName) } + histogramSuffixes := []string{"_bucket", "_count", "_sum"} + for _, suffix := range histogramSuffixes { + if strings.HasSuffix(metricName, suffix) { + if r.MetricConflicts(strings.TrimSuffix(metricName, suffix), metrics.CounterMetricType) { + return nil, fmt.Errorf("metric with name %s is already registered", metricName) + } + } + } + var counterVec *prometheus.CounterVec if vh == nil { metricsCount.WithLabelValues("counter").Inc()