Reduce lock-protected area during scrape.

Change-Id: Iaa7faa7c916b1890b568d05bd8bfff6299b6767d
This commit is contained in:
Bjoern Rabenstein 2014-12-05 19:40:41 +01:00
parent fee88a7a77
commit 89bb376bce
1 changed files with 2 additions and 3 deletions

View File

@ -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)