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 @metadata_entrypoint decorator #6084

Merged
merged 6 commits into from
Mar 31, 2020

Conversation

florimondmanca
Copy link
Contributor

@florimondmanca florimondmanca commented Mar 18, 2020

What does this PR do?

Provide a decorator for automatically performing certain tasks associated to metadata collection.

Motivation

  • Provide some standardization to how metadata collection is handled (i.e. encourage a submit-in-a-single-method style).
  • Make any automatic processing explicit (via the decorator marker).
  • Provide sufficient flexibility to implementers (eg classes can have multiple entrypoints; we can also consider providing a context manager for in-.check() usage without having to create separate methods).

Additional Notes

More explicit alternative to #6078
Refs #5748

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached

Copy link
Member

@mgarabed mgarabed left a comment

Choose a reason for hiding this comment

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

In general, not sure if I like this proposal - the extra import and decorator seems pretty heavy for a relatively light functionality benefit.

@florimondmanca
Copy link
Contributor Author

florimondmanca commented Mar 24, 2020

Updated the PR to reflect the latest state of discussions.

Personally I'm a bit less convinced this is worth it:

  • Doing automatic catch-all exception handling actually doesn't sound right (if metadata collection is broken in an integration we should fix it instead of silence exceptions as debug logs).
  • This means this would just be an API for an if statement, but it's not easy to backport since not all integrations use the one-method-to-collect-metadata style. (So we might as well just to a pass to verify that .is_metadata_collection_enabled() is checked wherever it makes sense…) At least we'd have it for newer integrations though.

hithwen
hithwen previously approved these changes Mar 24, 2020
ofek
ofek previously approved these changes Mar 24, 2020
@florimondmanca florimondmanca dismissed stale reviews from ofek and hithwen via 4ff9081 March 25, 2020 10:02
Copy link
Contributor

@ofek ofek left a comment

Choose a reason for hiding this comment

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

💯

@ofek
Copy link
Contributor

ofek commented Mar 31, 2020

./datadog_checks/base/checks/win/winpdh.py:133:81: W291 trailing whitespace

@florimondmanca florimondmanca mentioned this pull request Mar 31, 2020
4 tasks
@florimondmanca
Copy link
Contributor Author

CI failures are unrelated (E2E flakes, Envoy "No Go files…"), merging…

@florimondmanca florimondmanca merged commit 8c20b20 into master Mar 31, 2020
@florimondmanca florimondmanca deleted the florimondmanca/metadata-decorator branch March 31, 2020 15:42
@florimondmanca florimondmanca mentioned this pull request Jun 22, 2020
4 tasks
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