-
Notifications
You must be signed in to change notification settings - Fork 877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add redacted addr to scrapeRedisHost error message (#638) #643
Conversation
Pull Request Test Coverage Report for Build 1560
💛 - Coveralls |
Codecov Report
@@ Coverage Diff @@
## master #643 +/- ##
==========================================
- Coverage 88.24% 88.07% -0.18%
==========================================
Files 16 16
Lines 1922 1928 +6
==========================================
+ Hits 1696 1698 +2
- Misses 152 154 +2
- Partials 74 76 +2
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one comment
exporter/exporter.go
Outdated
@@ -527,7 +528,13 @@ 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, _ := url.Parse(e.redisAddr); redisURL != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe catch the error here instead of checking the result for nil? You could then output the error in the else block in log level debug to add addtl information.
@neomantra - do you still plan to make changes on this? I think surfacing the error would be good. |
I’ll incorporate that feedback today, thanks. |
I updated this per your comment and rebased to latest master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
When
scrapeRedisHost
fails to connect to a Redis instance, the code now tries to redact the password of the Redis address (URL). If it can parse and redact it, it will print the address in the error message. Otherwise, we note that-debug
is needed to see the address. It does not log any URL parsing errors, just in case that may leak any info.Testing: