retrieval: fix missing scrape context cancellation (#2599)

This commit is contained in:
Julius Volz 2017-05-11 16:15:07 +02:00 committed by GitHub
parent 0c3462762b
commit f160f17a6f
1 changed files with 2 additions and 1 deletions

View File

@ -413,7 +413,7 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) {
if !sl.appender.NeedsThrottling() {
var (
start = time.Now()
scrapeCtx, _ = context.WithTimeout(sl.ctx, timeout)
scrapeCtx, cancel = context.WithTimeout(sl.ctx, timeout)
numPostRelabelSamples = 0
)
@ -425,6 +425,7 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) {
}
samples, err := sl.scraper.scrape(scrapeCtx, start)
cancel()
if err == nil {
numPostRelabelSamples, err = sl.append(samples)
}