forked from mirrors/statsd_exporter
Fixing clash problem when counter clashes with previous registered histogram
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
This commit is contained in:
parent
30c3e31574
commit
7afa060ce4
1 changed files with 10 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue