From 76b3378190ec7301017a87d2b9feb67a973faf75 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Thu, 11 May 2017 17:20:03 +0200 Subject: [PATCH] retrieval: add missing scrape context cancelation --- retrieval/scrape.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/retrieval/scrape.go b/retrieval/scrape.go index 98e15fb005..0186712e76 100644 --- a/retrieval/scrape.go +++ b/retrieval/scrape.go @@ -469,9 +469,9 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) { } var ( - total, added int - start = time.Now() - scrapeCtx, _ = context.WithTimeout(sl.ctx, timeout) + total, added int + start = time.Now() + scrapeCtx, cancel = context.WithTimeout(sl.ctx, timeout) ) // Only record after the first scrape. @@ -482,6 +482,7 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) { } err := sl.scraper.scrape(scrapeCtx, buf) + cancel() if err == nil { b := buf.Bytes()