web: Fix federation for instance label

This commit is contained in:
Fabian Reinartz 2017-04-05 14:53:34 +02:00
parent 47b0b9f7b0
commit 8c768f2ca3
2 changed files with 4 additions and 3 deletions

View file

@ -167,7 +167,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
Name: proto.String(l.Name),
Value: proto.String(l.Value),
})
if _, ok := h.externalLabels[model.LabelName(l.Name)]; ok {
if _, ok := externalLabels[model.LabelName(l.Name)]; ok {
globalUsed[l.Name] = struct{}{}
}
}
@ -176,7 +176,8 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
continue
}
// Attach global labels if they do not exist yet.
for ln, lv := range h.externalLabels {
for _, ln := range externalLabelNames {
lv := externalLabels[ln]
if _, ok := globalUsed[string(ln)]; !ok {
protMetric.Label = append(protMetric.Label, &dto.LabelPair{
Name: proto.String(string(ln)),

View file

@ -204,7 +204,7 @@ func TestFederation(t *testing.T) {
t.Errorf("Scenario %q: got code %d, want %d", name, got, want)
}
if got, want := normalizeBody(res.Body), scenario.body; got != want {
t.Errorf("Scenario %q: got body %s, want %s", name, got, want)
t.Errorf("Scenario %q: got body\n%s\n, want\n%s\n", name, got, want)
}
}
}