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

Refactor duplicate code in Cloud Monitoring backends #268

Open
lvaylet opened this issue Oct 22, 2022 · 1 comment · May be fixed by #292
Open

Refactor duplicate code in Cloud Monitoring backends #268

lvaylet opened this issue Oct 22, 2022 · 1 comment · May be fixed by #292
Assignees
Labels
invalid This doesn't seem right p/cloud_monitoring_mql p/cloud_monitoring Cloud Monitoring provider issue refactor

Comments

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 22, 2022

As highlighted by the # pylint: disable=duplicate-code comments, there is duplicate code in slo_generator/backends/cloud_monitoring.py and slo_generator/backends/cloud_monitoring_mql.py.

Refactor any duplicate code in a separate utils or helpers file, then remove these comments and confirm make lint completes successfully.

@lvaylet lvaylet self-assigned this Oct 22, 2022
@lvaylet lvaylet added invalid This doesn't seem right p/cloud_monitoring Cloud Monitoring provider issue p/cloud_monitoring_mql labels Oct 22, 2022
@lvaylet
Copy link
Collaborator Author

lvaylet commented Nov 4, 2022

In addition to utils or helpers, Abstract Base Classes (ABC) are good candidates to rationalize this duplicate code. As described in https://realpython.com/inheritance-composition-python/#abstract-base-classes-in-python:

Abstract base classes exist to be inherited, but never instantiated.

Classes who inherit from an ABC must implement all the methods decorated with @abstractmethod. good_bad_ratio, distribution_cut and query are probably good candidates for such abstract methods, as every backend must implement them. If so, would it make sense to refactor all the backends instead of just the Cloud Monitoring ones?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right p/cloud_monitoring_mql p/cloud_monitoring Cloud Monitoring provider issue refactor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant