-
Notifications
You must be signed in to change notification settings - Fork 30
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
Refine API wrapper for "Plugins" #114
Conversation
9541818
to
30a0c40
Compare
Codecov Report
@@ Coverage Diff @@
## main #114 +/- ##
==========================================
- Coverage 95.15% 94.85% -0.31%
==========================================
Files 25 25
Lines 1590 1594 +4
==========================================
- Hits 1513 1512 -1
- Misses 77 82 +5
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
except Exception as ex: | ||
self.logger.info("Got error in fetching metrics for plugin %s and error = %s", pluginId, ex) | ||
return None | ||
path = "/plugins/%s/metrics" % pluginId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for refactoring. I should have put more focus here since that was my local logging to help identify if plugin does not have metrics endpoint.
@@ -34,10 +26,15 @@ def install_plugin(self, pluginId, version): | |||
r = self.client.POST(path, json={"version": version}) | |||
return r | |||
except Exception as ex: | |||
self.logger.info("Skipped installing %s and err = %s", pluginId, ex) | |||
if errors == "raise": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great one, thanks for helping raise the quality.
About
This patch refines GH-110 by @bhks a bit. First, the wrapper functions in the other subsystem implementations usually do not catch exceptions, which led to an anomaly in error handling at grafana-toolbox/grafana-wtf#91. In order to align it to the other wrapper implementations, I've removed catching exceptions in the
get_plugin_metrics
function.On the other hand, I've added error handling to the
{install,uninstall}_plugin
functions, now raising errors by default, but providing the possibility to ignore them.