lib/promscrape: properly remove deleted target from /targets page

Previously `sw` variable wasn't captured correctly by the started goroutine.
This commit is contained in:
Aliaksandr Valialkin 2020-12-15 20:56:16 +02:00
parent 49e800ba55
commit c4ec977934

View file

@ -318,14 +318,14 @@ func (sg *scraperGroup) update(sws []*ScrapeWork) {
sg.activeScrapers.Inc()
sg.scrapersStarted.Inc()
sg.wg.Add(1)
go func() {
tsmGlobal.Register(sw)
go func(sw *ScrapeWork) {
defer sg.wg.Done()
sc.sw.run(sc.stopCh)
tsmGlobal.Unregister(sw)
sg.activeScrapers.Dec()
sg.scrapersStopped.Inc()
}()
tsmGlobal.Register(sw)
}(sw)
sg.m[key] = sc
additionsCount++
}