use labels.FromMap

Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
Augustin Husson 2022-07-04 13:46:49 +02:00
parent e8e639dbc9
commit 68fa39880e
No known key found for this signature in database
GPG key ID: 99776005FB44BFC1

View file

@ -18,7 +18,6 @@ import (
"hash/fnv"
"net"
"net/url"
"sort"
"strings"
"sync"
"time"
@ -534,16 +533,7 @@ func buildTargetLabels(targetLSet, targetGroupLSet model.LabelSet, cfg *config.S
set(labelsMap, model.ParamLabelPrefix+k, v[0])
}
}
return buildLabels(labelsMap)
}
func buildLabels(ls map[string]string) labels.Labels {
var result labels.Labels = make([]labels.Label, 0, len(ls))
for k, v := range ls {
result = append(result, labels.Label{Name: k, Value: v})
}
sort.Sort(result)
return result
return labels.FromMap(labelsMap)
}
func set(ls map[string]string, k, v string) {