-
Notifications
You must be signed in to change notification settings - Fork 168
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
Switch logging to go-kit #144
Conversation
07e4f06
to
b430f04
Compare
Code looks good, can you add the DCO? Test failure looks like a CI issue, retrying. |
Ah, you need to update the vendoring. |
43a649e
to
dd35b0e
Compare
@brian-brazil Thanks for the input! updated the vendoring and ammended to the same commit. |
452dc52
to
07eeca7
Compare
@sowmiyamuthuraman you need to update scripts/errcheck_excludes.txt to pass the CI (see here). |
2e80952
to
0f1e157
Compare
@sowmiyamuthuraman can you rebase on master and update the |
Signed-off-by: sowmiya <[email protected]>
0f1e157
to
48b88be
Compare
@simonpasquier i resolved the conflicts and updated the scripts/errcheck_excludes.txt. Can you please help in passing the test? |
Signed-off-by: Simon Pasquier <[email protected]>
I've pushed an update to your branch to fix the Tests are failing because |
Signed-off-by: sowmiyamuthuraman <[email protected]>
16d7bd5
to
e1d68a6
Compare
Thanks, @simonpasquier. I have made the suggested changes and amended with the same commit |
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.
Good work! Just a few comments and it should be good to go.
consul_exporter.go
Outdated
@@ -170,6 +177,7 @@ func NewExporter(opts consulOpts, kvPrefix, kvFilter string, healthSummary bool) | |||
kvPrefix: kvPrefix, | |||
kvFilter: regexp.MustCompile(kvFilter), | |||
healthSummary: healthSummary, | |||
logger: log.NewLogfmtLogger(os.Stdout), |
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.
You should modify the NewExporter
function to add a log.Logger
parameter and pass it here.
consul_exporter.go
Outdated
|
||
func (l promHTTPLogger) Println(v ...interface{}) { | ||
log.Error(v...) | ||
level.Error(l.logger).Log("msg", v) |
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.
rather level.Error(l.logger).Log("msg", fmt.Sprintf(v))
consul_exporter.go
Outdated
@@ -441,7 +452,9 @@ func main() { | |||
promhttp.HandlerFor( | |||
prometheus.DefaultGatherer, | |||
promhttp.HandlerOpts{ | |||
ErrorLog: &promHTTPLogger{}, | |||
ErrorLog: &promHTTPLogger{ | |||
logger: log.NewLogfmtLogger(os.Stderr), |
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.
logger
instead of log.NewLogfmtLogger(os.Stderr)
consul_exporter.go
Outdated
|
||
exporter, err := NewExporter(opts, *kvPrefix, *kvFilter, *healthSummary) | ||
if err != nil { | ||
log.Fatalln(err) | ||
level.Error(logger).Log("msg", "Error creating an exporter", "err", err) |
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.
(nit) Error creating the exporter
consul_exporter.go
Outdated
log.Infoln("Starting consul_exporter", version.Info()) | ||
log.Infoln("Build context", version.BuildContext()) | ||
level.Info(logger).Log("msg", "Starting consul_exporter", "version", version.Info()) | ||
level.Info(logger).Log("msg", "Build context", version.BuildContext()) |
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.
Arguments to Log()
should always be even (key+value) so:
level.Info(logger).Log("build_context", version.BuildContext())
consul_exporter.go
Outdated
@@ -330,14 +338,14 @@ func (e *Exporter) collectHealthSummary(ch chan<- prometheus.Metric, serviceName | |||
func (e *Exporter) collectOneHealthSummary(ch chan<- prometheus.Metric, serviceName string) { | |||
// See https://github.com/hashicorp/consul/issues/1096. | |||
if strings.HasPrefix(serviceName, "/") { | |||
log.Warnf("Skipping service %q because it starts with a slash", serviceName) | |||
level.Warn(e.logger).Log("msg", "Skipping service because it starts with a slash", "service name", serviceName) |
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.
"service name" -> "service_name"
Signed-off-by: sowmiyamuthuraman <[email protected]>
consul_exporter.go
Outdated
|
||
func (l promHTTPLogger) Println(v ...interface{}) { | ||
log.Error(v...) | ||
level.Error(l.logger).Log("msg", fmt.Sprintf("%v", v)) |
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.
Sorry my previous comment was confusing, it should be level.Error(l.logger).Log("msg", fmt.Sprint(v...))
As #145 got merged, you'd need to rebase on master and adjust the changes. Sorry for the incovenience! |
1ae411c
to
7993c6b
Compare
Signed-off-by: sowmiyamuthuraman <[email protected]>
7993c6b
to
b9e4941
Compare
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.
👍
Thanks for the work! |
Fixes #141