lib/promscrape: reduce memory allocations in mergeLabels() after 48e3e6c8df

This commit is contained in:
Aliaksandr Valialkin 2021-09-30 16:56:12 +03:00
parent ec6eb03d65
commit 522a404b79
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -1163,7 +1163,7 @@ func getParamsFromLabels(labels []prompbmarshal.Label, paramsOrig map[string][]s
func mergeLabels(swc *scrapeWorkConfig, target string, extraLabels, metaLabels map[string]string) []prompbmarshal.Label { func mergeLabels(swc *scrapeWorkConfig, target string, extraLabels, metaLabels map[string]string) []prompbmarshal.Label {
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config // See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
m := make(map[string]string, 4+len(swc.externalLabels)+len(swc.params)+len(extraLabels)+len(metaLabels)) m := make(map[string]string, 6+len(swc.externalLabels)+len(swc.params)+len(extraLabels)+len(metaLabels))
for k, v := range swc.externalLabels { for k, v := range swc.externalLabels {
m[k] = v m[k] = v
} }