From 0c09c3feb021a45a87bd99dfc44ccadfa14deb21 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 7 Mar 2023 17:17:49 +0000 Subject: [PATCH] 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 --- scrape/scrape.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrape/scrape.go b/scrape/scrape.go index 5c71a0110..01c66ca81 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -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) } }