|
|
@ -288,24 +288,10 @@ func (m *Manager) TargetsActive() map[string][]*Target {
|
|
|
|
m.mtxScrape.Lock()
|
|
|
|
m.mtxScrape.Lock()
|
|
|
|
defer m.mtxScrape.Unlock()
|
|
|
|
defer m.mtxScrape.Unlock()
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
|
|
|
wg sync.WaitGroup
|
|
|
|
|
|
|
|
mtx sync.Mutex
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
targets := make(map[string][]*Target, len(m.scrapePools))
|
|
|
|
targets := make(map[string][]*Target, len(m.scrapePools))
|
|
|
|
wg.Add(len(m.scrapePools))
|
|
|
|
|
|
|
|
for tset, sp := range m.scrapePools {
|
|
|
|
for tset, sp := range m.scrapePools {
|
|
|
|
// Running in parallel limits the blocking time of scrapePool to scrape
|
|
|
|
targets[tset] = sp.ActiveTargets()
|
|
|
|
// interval when there's an update from SD.
|
|
|
|
|
|
|
|
go func(tset string, sp *scrapePool) {
|
|
|
|
|
|
|
|
mtx.Lock()
|
|
|
|
|
|
|
|
targets[tset] = sp.ActiveTargets()
|
|
|
|
|
|
|
|
mtx.Unlock()
|
|
|
|
|
|
|
|
wg.Done()
|
|
|
|
|
|
|
|
}(tset, sp)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
|
|
|
return targets
|
|
|
|
return targets
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|