Remove redundant __name__ label from protobuf output.

Change-Id: I72d5dbccb0325d6edf7abe5bca88dc5a6001029c
This commit is contained in:
Bjoern Rabenstein 2014-04-03 15:18:12 +02:00
parent ee34486fa1
commit b83e1b7cad
2 changed files with 7 additions and 12 deletions

View File

@ -281,6 +281,13 @@ func (r *registry) dumpDelimitedPB(w io.Writer) {
container.Metric.dumpChildren(f) container.Metric.dumpChildren(f)
for name, value := range container.BaseLabels { for name, value := range container.BaseLabels {
if model.LabelName(name) == model.MetricNameLabel {
// The name is already in MetricFamily.
continue
// TODO: Once JSON is history, do not anymore
// add the __name__ label to BaseLabels and
// then remove this check.
}
p := &dto.LabelPair{ p := &dto.LabelPair{
Name: proto.String(name), Name: proto.String(name),
Value: proto.String(value), Value: proto.String(value),

View File

@ -229,10 +229,6 @@ func testHandler(t tester) {
Name: proto.String("externalbasename"), Name: proto.String("externalbasename"),
Value: proto.String("externalbasevalue"), Value: proto.String("externalbasevalue"),
}, },
&dto.LabelPair{
Name: proto.String("__name__"),
Value: proto.String("externalname"),
},
}, },
Counter: &dto.Counter{ Counter: &dto.Counter{
Value: proto.Float64(1), Value: proto.Float64(1),
@ -272,10 +268,6 @@ func testHandler(t tester) {
Name: proto.String("basename"), Name: proto.String("basename"),
Value: proto.String("basevalue"), Value: proto.String("basevalue"),
}, },
&dto.LabelPair{
Name: proto.String("__name__"),
Value: proto.String("name"),
},
}, },
Counter: &dto.Counter{ Counter: &dto.Counter{
Value: proto.Float64(1), Value: proto.Float64(1),
@ -291,10 +283,6 @@ func testHandler(t tester) {
Name: proto.String("basename"), Name: proto.String("basename"),
Value: proto.String("basevalue"), Value: proto.String("basevalue"),
}, },
&dto.LabelPair{
Name: proto.String("__name__"),
Value: proto.String("name"),
},
}, },
Counter: &dto.Counter{ Counter: &dto.Counter{
Value: proto.Float64(1), Value: proto.Float64(1),