From b308e073a0ffcba7f1c3903de33850950daf8f62 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 31 Oct 2021 14:46:40 +0300 Subject: [PATCH] fixup metric labels helper Signed-off-by: Vasiliy Tolstov --- victoriametrics.go | 4 ++-- victoriametrics_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/victoriametrics.go b/victoriametrics.go index 2884056..6f6294b 100644 --- a/victoriametrics.go +++ b/victoriametrics.go @@ -47,10 +47,10 @@ func (r *victoriametricsMeter) buildName(name string, labels ...string) string { return meter.BuildName(name, nlabels...) } - for idx := 0; idx <= len(nlabels)/2; idx += 2 { + for idx := 0; idx < nl; idx++ { nlabels[idx] = r.opts.LabelPrefix + nlabels[idx] + idx++ } - return meter.BuildName(name, nlabels...) } diff --git a/victoriametrics_test.go b/victoriametrics_test.go index b5c5b82..7851516 100644 --- a/victoriametrics_test.go +++ b/victoriametrics_test.go @@ -14,8 +14,8 @@ import ( func TestBuildName(t *testing.T) { m := NewMeter() im := m.(*victoriametricsMeter) - check := `micro_foo{micro_aaa="b",micro_bar="baz"}` - name := im.buildName("foo", "bar", "baz", "aaa", "b") + check := `micro_foo{micro_aaa="b",micro_bar="baz",micro_ccc="d"}` + name := im.buildName("foo", "bar", "baz", "aaa", "b", "ccc", "d") if name != check { t.Fatalf("metric name error: %s != %s", name, check) }