fix: only the latest scraper being run (#23813)

* fix: only the latest scraper being run

This is due to the Golang for-loop variable problem.

* chore: improve code readability
pull/23836/head
Jeffrey Smith II 2022-10-20 13:33:41 -04:00 committed by GitHub
parent 81e2ec617d
commit e61485a847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -121,11 +121,11 @@ func (s *Scheduler) doGather() {
s.log.Error("Cannot list targets", zap.Error(err)) s.log.Error("Cannot list targets", zap.Error(err))
return return
} }
for _, target := range targets { for i := range targets {
select { select {
case s.scrapeRequest <- &target: case s.scrapeRequest <- &targets[i]:
default: default:
s.log.Warn("Skipping scrape due to scraper backlog", zap.String("target", target.Name)) s.log.Warn("Skipping scrape due to scraper backlog", zap.String("target", targets[i].Name))
} }
} }
} }