-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactoring: use logger from base metricset #11754
Conversation
Pinging @elastic/stack-monitoring |
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.
PR LGTM.
I would suggest in a second PR to go to the new error interface. I remember trying to do this in the past but it cause some issues on the testing side as I did not migrate all metricsets at once. So let's merge this first and then do the second step as it's perhaps more complex.
@@ -60,19 +60,19 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) { | |||
isMaster, err := elasticsearch.IsMaster(m.HTTP, m.GetServiceURI()) | |||
if err != nil { | |||
err = errors.Wrap(err, "error determining if connected Elasticsearch node is master") | |||
elastic.ReportAndLogError(err, r, m.Log) | |||
elastic.ReportAndLogError(err, r, m.Logger()) |
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.
Why not directly go to func (m *MetricSet) Fetch(r mb.ReporterV2) error {
interface and return the error so you don't have to do this additional code as the new interface will do it for you?
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.
Yeah, I was planning on putting up a PR following your work in #10727 today.
return | ||
} | ||
|
||
info, err := elasticsearch.GetInfo(m.HTTP, m.GetServiceURI()) | ||
if err != nil { | ||
elastic.ReportAndLogError(err, r, m.Log) | ||
elastic.ReportAndLogError(err, r, m.Logger()) |
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.
See comment above.
@@ -81,22 +81,22 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) { | |||
ccrUnavailableMessage, err := m.checkCCRAvailability(info.Version.Number) | |||
if err != nil { | |||
err = errors.Wrap(err, "error determining if CCR is available") | |||
elastic.ReportAndLogError(err, r, m.Log) | |||
elastic.ReportAndLogError(err, r, m.Logger()) |
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.
See comment above.
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.
Pending the change suggestions offered by @ruflin the rest looks good to me.
With #11106, the base
Metricset
struct started defining aLogger()
method which returned a*logp.Logger
for metricsets to use. With this change, each metricset no longer needs to define its own logger.This PR updates Elastic Stack metricsets to use the base
Metricset
'sLogger()
instead of defining their own.