Skip to content
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

Refactoring: use logger from base metricset #11754

Merged
merged 1 commit into from
Apr 11, 2019

Conversation

ycombinator
Copy link
Contributor

With #11106, the base Metricset struct started defining a Logger() 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's Logger() instead of defining their own.

@ycombinator ycombinator requested a review from a team as a code owner April 11, 2019 00:32
@elasticmachine
Copy link
Collaborator

Pinging @elastic/stack-monitoring

Copy link
Member

@ruflin ruflin left a 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())
Copy link
Member

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?

Copy link
Contributor Author

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())
Copy link
Member

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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above.

Copy link
Contributor

@cachedout cachedout left a 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.

@ycombinator ycombinator merged commit 6d07f89 into elastic:master Apr 11, 2019
@ycombinator ycombinator deleted the refactoring-mb-logger branch December 25, 2019 11:17
@ycombinator ycombinator removed the needs_backport PR is waiting to be backported to other branches. label Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants