Skip to content

Commit

Permalink
fix: only the latest scraper being run (#23813)
Browse files Browse the repository at this point in the history
* fix: only the latest scraper being run

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

* chore: improve code readability
  • Loading branch information
jeffreyssmith2nd authored Oct 20, 2022
1 parent 81e2ec6 commit e61485a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gather/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ func (s *Scheduler) doGather() {
s.log.Error("Cannot list targets", zap.Error(err))
return
}
for _, target := range targets {
for i := range targets {
select {
case s.scrapeRequest <- &target:
case s.scrapeRequest <- &targets[i]:
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))
}
}
}
Expand Down

0 comments on commit e61485a

Please sign in to comment.