Merge pull request #11787 from damnever/perf/avoid-alloc-if-no-externallabels

Avoid allocation during remote write if external labels is empty
This commit is contained in:
Julien Pivotto 2023-02-22 23:38:21 +01:00 committed by GitHub
commit 475f9984d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -894,6 +894,10 @@ func (t *QueueManager) releaseLabels(ls labels.Labels) {
// processExternalLabels merges externalLabels into ls. If ls contains
// a label in externalLabels, the value in ls wins.
func processExternalLabels(ls labels.Labels, externalLabels []labels.Label) labels.Labels {
if len(externalLabels) == 0 {
return ls
}
b := labels.NewScratchBuilder(ls.Len() + len(externalLabels))
j := 0
ls.Range(func(l labels.Label) {