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

Add more detailed errors and tests in the windows/service metricset #17725

Merged
merged 8 commits into from
Apr 21, 2020

Conversation

narph
Copy link
Contributor

@narph narph commented Apr 15, 2020

What does this PR do?

Add more detailed error messages, system tests and small refactoring to the service metricset in windows.

Why is it important?

Preparing to move to GA

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@narph narph self-assigned this Apr 15, 2020
@narph narph added [zube]: In Review Metricbeat Metricbeat Team:Integrations Label for the Integrations team labels Apr 15, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

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.

Nice change, I have some questions, nothing serious.

// errorNames is mapping of errno values to names.
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms681383(v=vs.85).aspx
errorNames = map[uint32]string{
1077: "ERROR_SERVICE_NEVER_STARTED",
Copy link
Member

Choose a reason for hiding this comment

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

Is this error somehow special? Would we want to add more error names here?

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 sure why there is only one, this could be the most common one but I would either add several more or strip this entire logic all together and just retrieve the error code. I would go for the latter, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me. As it comes from the existing code we can also leave this for a separated change.

// getServiceID returns a unique ID for the service that is derived from the
// machine's GUID and the service's name.
func (reader *Reader) getServiceID(name string) string {
// hash returns a base64 encoded sha256 hash that is truncated to 10 chars.
Copy link
Member

Choose a reason for hiding this comment

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

Why truncating?

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 sure, this seems to be a custom function that builds a unique service ID so users can distinct between services on different machines. I think the truncation is just to have a standard format for it. (just guessing here)

metricbeat/module/windows/service/reader_test.go Outdated Show resolved Hide resolved
metricbeat/module/windows/service/service_status.go Outdated Show resolved Hide resolved
metricbeat/module/windows/service/service_status.go Outdated Show resolved Hide resolved
@narph narph added needs_backport PR is waiting to be backported to other branches. v7.8.0 labels Apr 21, 2020
@narph narph requested a review from jsoriano April 21, 2020 12:06
@narph narph merged commit c51a3bf into elastic:master Apr 21, 2020
@narph narph deleted the service-tests branch April 21, 2020 14:30
narph added a commit to narph/beats that referenced this pull request Apr 21, 2020
…lastic#17725)

* error details, tests

* changelog

* work on tests

* refactoring

* mage fmt

* mage fmt

(cherry picked from commit c51a3bf)
narph added a commit that referenced this pull request Apr 22, 2020
…windows/service metricset (#17872)

* Add more detailed errors and tests in the windows/service metricset (#17725)

* error details, tests

* changelog

* work on tests

* refactoring

* mage fmt

* mage fmt

(cherry picked from commit c51a3bf)

* update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Metricbeat Metricbeat needs_backport PR is waiting to be backported to other branches. Team:Integrations Label for the Integrations team v7.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants