Skip to content

Commit

Permalink
Expose failure to detect duplicate label names
Browse files Browse the repository at this point in the history
This is #471.

Signed-off-by: beorn7 <[email protected]>
  • Loading branch information
beorn7 committed Sep 30, 2018
1 parent ff01778 commit ddbeb59
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions prometheus/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,29 @@ collected metric named "complex_count" collides with previously collected summar
collected metric named "complex_count" collides with previously collected histogram named "complex"
`)
externalMetricFamilyWithDuplicateLabel := &dto.MetricFamily{
Name: proto.String("broken_metric"),
Help: proto.String("The registry should detect the duplicate label."),
Type: dto.MetricType_COUNTER.Enum(),
Metric: []*dto.Metric{
{
Label: []*dto.LabelPair{
{
Name: proto.String("foo"),
Value: proto.String("bar"),
},
{
Name: proto.String("foo"),
Value: proto.String("baz"),
},
},
Counter: &dto.Counter{
Value: proto.Float64(2.7),
},
},
},
}
duplicateLabelMsg := []byte(`duplicate label mumble mumble`)

type output struct {
headers map[string]string
Expand Down Expand Up @@ -646,6 +669,20 @@ collected metric named "complex_count" collides with previously collected histog
externalMetricFamilyWithBucketSuffix,
},
},
{ // 22
headers: map[string]string{
"Accept": "text/plain",
},
out: output{
headers: map[string]string{
"Content-Type": `text/plain; version=0.0.4; charset=utf-8`,
},
body: duplicateLabelMsg,
},
externalMF: []*dto.MetricFamily{
externalMetricFamilyWithDuplicateLabel,
},
},
}
for i, scenario := range scenarios {
registry := prometheus.NewPedanticRegistry()
Expand Down

0 comments on commit ddbeb59

Please sign in to comment.