From 89bb376bceb74d164c27f17b42e258f1b12a12e8 Mon Sep 17 00:00:00 2001 From: Bjoern Rabenstein Date: Fri, 5 Dec 2014 19:40:41 +0100 Subject: [PATCH] Reduce lock-protected area during scrape. Change-Id: Iaa7faa7c916b1890b568d05bd8bfff6299b6767d --- retrieval/target.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/retrieval/target.go b/retrieval/target.go index 1a134b9cd..621ea1d76 100644 --- a/retrieval/target.go +++ b/retrieval/target.go @@ -297,15 +297,14 @@ func (t *target) scrape(ingester extraction.Ingester) (err error) { t.Lock() // Writing t.state and t.lastError requires the lock. if err == nil { t.state = ALIVE - t.recordScrapeHealth(ingester, timestamp, true) labels[outcome] = failure } else { t.state = UNREACHABLE - t.recordScrapeHealth(ingester, timestamp, false) } - targetOperationLatencies.With(labels).Observe(ms) t.lastError = err t.Unlock() + targetOperationLatencies.With(labels).Observe(ms) + t.recordScrapeHealth(ingester, timestamp, err == nil) }(time.Now()) req, err := http.NewRequest("GET", t.Address(), nil)