scrape sync: avoid copy of labels for dropped targets

Since the Target object was just created in this function, nobody else
has a reference to it and there are no concerns about it being modified
concurrently so we don't need to copy the value.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2023-03-07 17:17:49 +00:00
parent 0dfa1e73f8
commit 0c09c3feb0
1 changed files with 1 additions and 1 deletions

View File

@ -505,7 +505,7 @@ func (sp *scrapePool) Sync(tgs []*targetgroup.Group) {
t.LabelsRange(func(l labels.Label) { nonEmpty = true })
if nonEmpty {
all = append(all, t)
} else if !t.DiscoveredLabels().IsEmpty() {
} else if !t.discoveredLabels.IsEmpty() {
sp.droppedTargets = append(sp.droppedTargets, t)
}
}