From fbe251c2df399b89bf87a11352ab26aff676d8d0 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Thu, 25 Feb 2016 14:05:42 +0100 Subject: [PATCH] Fix scrape interval length calculation --- retrieval/scrape.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/retrieval/scrape.go b/retrieval/scrape.go index 6ec7084ed..507dab878 100644 --- a/retrieval/scrape.go +++ b/retrieval/scrape.go @@ -235,9 +235,12 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) { scrapeCtx, _ = context.WithTimeout(sl.ctx, timeout) ) - targetIntervalLength.WithLabelValues(interval.String()).Observe( - float64(time.Since(last)) / float64(time.Second), // Sub-second precision. - ) + // Only record after the first scrape. + if !last.IsZero() { + targetIntervalLength.WithLabelValues(interval.String()).Observe( + float64(time.Since(last)) / float64(time.Second), // Sub-second precision. + ) + } samples, err := sl.scraper.scrape(scrapeCtx, start) if err == nil {