Drain the newBaseLabels channel upon shutdown.

This should help cut down shutdown times.

Change-Id: I6e70a598a9e49aa6eeeb2034105b1bc6e9014324
This commit is contained in:
Bjoern Rabenstein 2014-11-11 16:41:20 +01:00
parent 3f61d304ce
commit 92156ee89d
1 changed files with 12 additions and 0 deletions

View File

@ -207,6 +207,18 @@ func (t *target) recordScrapeHealth(ingester extraction.Ingester, timestamp clie
// RunScraper implements Target.
func (t *target) RunScraper(ingester extraction.Ingester, interval time.Duration) {
defer func() {
// Need to drain t.newBaseLabels to not make senders block during shutdown.
for {
select {
case <-t.newBaseLabels:
// Do nothing.
default:
return
}
}
}()
jitterTimer := time.NewTimer(time.Duration(float64(interval) * rand.Float64()))
select {
case <-jitterTimer.C: