meter: fast path for only one label
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
650d167313
commit
a7e6d61b95
@ -105,6 +105,7 @@ func BuildName(name string, labels ...string) string {
|
||||
labels = labels[:len(labels)-1]
|
||||
}
|
||||
|
||||
if len(labels) > 2 {
|
||||
sort.Sort(byKey(labels))
|
||||
|
||||
idx := 0
|
||||
@ -119,6 +120,7 @@ func BuildName(name string, labels ...string) string {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var b strings.Builder
|
||||
_, _ = b.WriteString(name)
|
||||
|
@ -56,6 +56,10 @@ func TestBuildName(t *testing.T) {
|
||||
"my_metric",
|
||||
"broker", "broker1", "broker", "broker2", "server", "http", "server", "tcp", "register", "mdns",
|
||||
},
|
||||
`my_metric{aaa="aaa"}`: []string{
|
||||
"my_metric",
|
||||
"aaa", "aaa",
|
||||
},
|
||||
}
|
||||
|
||||
for e, d := range data {
|
||||
|
Loading…
x
Reference in New Issue
Block a user