mirror of
https://github.com/prometheus/prometheus
synced 2025-01-11 17:19:45 +00:00
Refactor: scraping: extract method restartLoops
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
b42b5fbd74
commit
74b1f3daa6
@ -274,6 +274,15 @@ func (sp *scrapePool) reload(cfg *config.ScrapeConfig) error {
|
||||
|
||||
sp.metrics.targetScrapePoolTargetLimit.WithLabelValues(sp.config.JobName).Set(float64(sp.config.TargetLimit))
|
||||
|
||||
sp.restartLoops(reuseCache)
|
||||
oldClient.CloseIdleConnections()
|
||||
sp.metrics.targetReloadIntervalLength.WithLabelValues(time.Duration(sp.config.ScrapeInterval).String()).Observe(
|
||||
time.Since(start).Seconds(),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sp *scrapePool) restartLoops(reuseCache bool) {
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
interval = time.Duration(sp.config.ScrapeInterval)
|
||||
@ -314,7 +323,7 @@ func (sp *scrapePool) reload(cfg *config.ScrapeConfig) error {
|
||||
client: sp.client,
|
||||
timeout: timeout,
|
||||
bodySizeLimit: bodySizeLimit,
|
||||
acceptHeader: acceptHeader(cfg.ScrapeProtocols),
|
||||
acceptHeader: acceptHeader(sp.config.ScrapeProtocols),
|
||||
acceptEncodingHeader: acceptEncodingHeader(enableCompression),
|
||||
}
|
||||
newLoop = sp.newLoop(scrapeLoopOptions{
|
||||
@ -353,11 +362,6 @@ func (sp *scrapePool) reload(cfg *config.ScrapeConfig) error {
|
||||
sp.targetMtx.Unlock()
|
||||
|
||||
wg.Wait()
|
||||
oldClient.CloseIdleConnections()
|
||||
sp.metrics.targetReloadIntervalLength.WithLabelValues(interval.String()).Observe(
|
||||
time.Since(start).Seconds(),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Must be called with sp.mtx held.
|
||||
|
Loading…
Reference in New Issue
Block a user