From b42b5fbd74627d5c5ea9fb38857fc7a4b55ebfe1 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 2 Apr 2024 18:42:40 +0100 Subject: [PATCH] Scraping: check symbol-table on sync Previously they were only checked on a change of config. Signed-off-by: Bryan Boreham --- scrape/scrape.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scrape/scrape.go b/scrape/scrape.go index c16f14cec..2655ffd16 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -357,7 +357,11 @@ func (sp *scrapePool) reload(cfg *config.ScrapeConfig) error { sp.metrics.targetReloadIntervalLength.WithLabelValues(interval.String()).Observe( time.Since(start).Seconds(), ) + return nil +} +// Must be called with sp.mtx held. +func (sp *scrapePool) checkSymbolTable() { // Here we take steps to clear out the symbol table if it has grown a lot. // After waiting some time for things to settle, we take the size of the symbol-table. // If, after some more time, the table has grown to twice that size, we start a new one. @@ -371,8 +375,6 @@ func (sp *scrapePool) reload(cfg *config.ScrapeConfig) error { } sp.lastSymbolTableCheck = time.Now() } - - return nil } // Sync converts target groups into actual scrape targets and synchronizes @@ -412,6 +414,7 @@ func (sp *scrapePool) Sync(tgs []*targetgroup.Group) { sp.metrics.targetScrapePoolSymbolTableItems.WithLabelValues(sp.config.JobName).Set(float64(sp.symbolTable.Len())) sp.targetMtx.Unlock() sp.sync(all) + sp.checkSymbolTable() sp.metrics.targetSyncIntervalLength.WithLabelValues(sp.config.JobName).Observe( time.Since(start).Seconds(),