diff --git a/scrape/target.go b/scrape/target.go index 0af2b8ba14..2e43750af7 100644 --- a/scrape/target.go +++ b/scrape/target.go @@ -190,9 +190,9 @@ func (t *Target) LabelsRange(f func(l labels.Label)) { // DiscoveredLabels returns a copy of the target's labels before any processing. func (t *Target) DiscoveredLabels(lb *labels.Builder) labels.Labels { - t.mtx.Lock() + t.mtx.RLock() cfg, tLabels, tgLabels := t.scrapeConfig, t.tLabels, t.tgLabels - t.mtx.Unlock() + t.mtx.RUnlock() PopulateDiscoveredLabels(lb, cfg, tLabels, tgLabels) return lb.Labels() } @@ -208,9 +208,9 @@ func (t *Target) SetScrapeConfig(scrapeConfig *config.ScrapeConfig, tLabels, tgL // URL returns a copy of the target's URL. func (t *Target) URL() *url.URL { - t.mtx.Lock() + t.mtx.RLock() configParams := t.scrapeConfig.Params - t.mtx.Unlock() + t.mtx.RUnlock() params := url.Values{} for k, v := range configParams {