From b90c7a55da04231643895b192d15d499adbc480f Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Tue, 6 Oct 2020 21:17:16 +0200 Subject: [PATCH] Simplify logic Signed-off-by: Julien Pivotto --- scrape/scrape.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scrape/scrape.go b/scrape/scrape.go index 6e81f4300..de248d876 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -990,8 +990,8 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) { var last time.Time - ticker := time.NewTicker(interval) alignedScrapeTime := time.Now() + ticker := time.NewTicker(interval) defer ticker.Stop() mainLoop: @@ -1016,7 +1016,7 @@ mainLoop: alignedScrapeTime = alignedScrapeTime.Add(interval) } // Align the scrape time if we are in the tolerance boundaries. - if t := scrapeTime.Sub(alignedScrapeTime); t >= -scrapeTimestampTolerance && t <= scrapeTimestampTolerance { + if scrapeTime.Sub(alignedScrapeTime) <= scrapeTimestampTolerance { scrapeTime = alignedScrapeTime } }