Skip to content

Commit

Permalink
Add redacted addr to scrapeRedisHost error message (#638) (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
neomantra authored Jun 3, 2022
1 parent 3afacfe commit 07709eb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package exporter
import (
"fmt"
"net/http"
"net/url"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -528,7 +529,14 @@ func (e *Exporter) scrapeRedisHost(ch chan<- prometheus.Metric) error {
e.registerConstMetricGauge(ch, "exporter_last_scrape_connect_time_seconds", connectTookSeconds)

if err != nil {
log.Errorf("Couldn't connect to redis instance")
var redactedAddr string
if redisURL, err2 := url.Parse(e.redisAddr); err2 != nil {
log.Debugf("url.Parse( %s ) err: %s", e.redisAddr, err2)
redactedAddr = "<redacted>"
} else {
redactedAddr = redisURL.Redacted()
}
log.Errorf("Couldn't connect to redis instance (%s)", redactedAddr)
log.Debugf("connectToRedis( %s ) err: %s", e.redisAddr, err)
return err
}
Expand Down

0 comments on commit 07709eb

Please sign in to comment.