Skip to content

Commit

Permalink
emit pg_scrape_error metric when no errors
Browse files Browse the repository at this point in the history
  • Loading branch information
apetruhin committed Jun 14, 2024
1 parent 312ec2a commit 9863128
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,12 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
c.lock.RLock()
defer c.lock.RUnlock()

for e := range c.scrapeErrors {
ch <- gauge(dScrapeError, 1, "", e)
if len(c.scrapeErrors) > 0 {
for e := range c.scrapeErrors {
ch <- gauge(dScrapeError, 1, "", e)
}
} else {
ch <- gauge(dScrapeError, 0, "", "")
}

c.connectionMetrics(ch)
Expand Down

0 comments on commit 9863128

Please sign in to comment.