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

Check return from report.Event and migrate to use ReportingMetricSetV2Error #11775

Merged
merged 5 commits into from
Apr 18, 2019
Merged

Check return from report.Event and migrate to use ReportingMetricSetV2Error #11775

merged 5 commits into from
Apr 18, 2019

Conversation

kaiyan-sheng
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng commented Apr 12, 2019

Instead of ignoring the return from report.Error, we should actually check the return to see if report event succeed or not. Please see #11666 for more details on this. Thanks @fearful-symmetry to bring this up.

This PR also removes moduleConfig.Period check in s3 metricset code because it's already done in
NewMetricSet in aws.go.

Copy link
Contributor

@exekias exekias left a comment

Choose a reason for hiding this comment

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

this is looking good but I would want a review from @fearful-symmetry or @ruflin who have been involved in the refactor

@fearful-symmetry
Copy link
Contributor

This looks good, as the added logging/reporting steps only happen inside a loop with continue. I'm not sure if we need to log something when the metricset closes, but @ruflin may disagree

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

If r.Event returns false doesn't mean that there was an error. This is just an indication that the module is being stopped, so no more processing is needed. We shouldn't generate errors in that case, just stop doing anymore requests if anything.

report.Event(event)

if reported := report.Event(event); !reported {
return errors.Wrap(err, "Error trying to emit event")
Copy link
Member

Choose a reason for hiding this comment

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

This is not an error, this is expected to happen. It only means that the module is being stopped. We interrupt the loop to avoid doing more requests or processing that are not going to be used.
Just log something at the debug level (or nothing at all), and return nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @jsoriano for the explanation!

x-pack/metricbeat/module/aws/sqs/sqs.go Outdated Show resolved Hide resolved

moduleConfig := aws.Config{}
if err := base.Module().UnpackConfig(&moduleConfig); err != nil {
return nil, err
}

if moduleConfig.Period == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this change related?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not related. Sorry forgot to update on the PR . This check is not needed here because it's already done in aws.NewMetricSet(base) in line 60.


moduleConfig := aws.Config{}
if err := base.Module().UnpackConfig(&moduleConfig); err != nil {
return nil, err
}

if moduleConfig.Period == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

See above.

x-pack/metricbeat/module/aws/sqs/sqs.go Outdated Show resolved Hide resolved
x-pack/metricbeat/module/aws/sqs/sqs.go Show resolved Hide resolved
@kaiyan-sheng kaiyan-sheng merged commit 95b5489 into elastic:master Apr 18, 2019
@kaiyan-sheng kaiyan-sheng deleted the check_reported branch April 18, 2019 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants