From a1ee77601aa93cda8c4711a6b3a860be45c0a4e3 Mon Sep 17 00:00:00 2001 From: stuart nelson Date: Wed, 9 Mar 2016 16:33:10 +0100 Subject: [PATCH] Instrument the duration of the `reload` function --- retrieval/scrape.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/retrieval/scrape.go b/retrieval/scrape.go index 3697a22168..a3e7e6d9cd 100644 --- a/retrieval/scrape.go +++ b/retrieval/scrape.go @@ -65,11 +65,21 @@ var ( }, []string{interval}, ) + targetReloadIntervalLength = prometheus.NewSummaryVec( + prometheus.SummaryOpts{ + Namespace: namespace, + Name: "target_reload_length_seconds", + Help: "Actual interval to reload the scrape pool with a given configuration.", + Objectives: map[float64]float64{0.01: 0.001, 0.05: 0.005, 0.5: 0.05, 0.90: 0.01, 0.99: 0.001}, + }, + []string{interval}, + ) ) func init() { prometheus.MustRegister(targetIntervalLength) prometheus.MustRegister(targetSkippedScrapes) + prometheus.MustRegister(targetReloadIntervalLength) } // scrapePool manages scrapes for sets of targets. @@ -132,6 +142,7 @@ func (sp *scrapePool) stop() { // but all scrape loops are restarted with the new scrape configuration. // This method returns after all scrape loops that were stopped have fully terminated. func (sp *scrapePool) reload(cfg *config.ScrapeConfig) { + start := time.Now() sp.mtx.Lock() defer sp.mtx.Unlock() @@ -168,6 +179,9 @@ func (sp *scrapePool) reload(cfg *config.ScrapeConfig) { } wg.Wait() + targetReloadIntervalLength.WithLabelValues(interval.String()).Observe( + float64(time.Since(start)) / float64(time.Second), + ) } // sync takes a list of potentially duplicated targets, deduplicates them, starts