fixup metric labels helper #49
@ -47,10 +47,10 @@ func (r *victoriametricsMeter) buildName(name string, labels ...string) string {
|
|||||||
return meter.BuildName(name, nlabels...)
|
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]
|
nlabels[idx] = r.opts.LabelPrefix + nlabels[idx]
|
||||||
|
idx++
|
||||||
}
|
}
|
||||||
|
|
||||||
return meter.BuildName(name, nlabels...)
|
return meter.BuildName(name, nlabels...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ import (
|
|||||||
func TestBuildName(t *testing.T) {
|
func TestBuildName(t *testing.T) {
|
||||||
m := NewMeter()
|
m := NewMeter()
|
||||||
im := m.(*victoriametricsMeter)
|
im := m.(*victoriametricsMeter)
|
||||||
check := `micro_foo{micro_aaa="b",micro_bar="baz"}`
|
check := `micro_foo{micro_aaa="b",micro_bar="baz",micro_ccc="d"}`
|
||||||
name := im.buildName("foo", "bar", "baz", "aaa", "b")
|
name := im.buildName("foo", "bar", "baz", "aaa", "b", "ccc", "d")
|
||||||
if name != check {
|
if name != check {
|
||||||
t.Fatalf("metric name error: %s != %s", name, check)
|
t.Fatalf("metric name error: %s != %s", name, check)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user