mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-06-22 06:50:32 +00:00
Merge pull request #216 from claytono/conflicting-histogram-fix
Check for histogram conflict on main name
This commit is contained in:
commit
f502171bdc
|
@ -262,6 +262,9 @@ func (c *HistogramContainer) Get(metricName string, labels prometheus.Labels, mc
|
||||||
|
|
||||||
histogramVec, ok := c.Elements[mapKey]
|
histogramVec, ok := c.Elements[mapKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if mc.metricConflicts(metricName, HistogramMetricType) {
|
||||||
|
return nil, fmt.Errorf("metric with name %s is already registered", metricName)
|
||||||
|
}
|
||||||
if mc.metricConflicts(metricName+"_sum", HistogramMetricType) {
|
if mc.metricConflicts(metricName+"_sum", HistogramMetricType) {
|
||||||
return nil, fmt.Errorf("metric with name %s is already registered", metricName)
|
return nil, fmt.Errorf("metric with name %s is already registered", metricName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,6 +238,20 @@ func TestConflictingMetrics(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "counter vs histogram",
|
||||||
|
expected: []float64{1},
|
||||||
|
in: Events{
|
||||||
|
&CounterEvent{
|
||||||
|
metricName: "histogram_test1",
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
&TimerEvent{
|
||||||
|
metricName: "histogram.test1",
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "counter vs histogram sum",
|
name: "counter vs histogram sum",
|
||||||
expected: []float64{1},
|
expected: []float64{1},
|
||||||
|
|
Loading…
Reference in a new issue