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

Refine API wrapper for "Plugins" #114

Merged
merged 2 commits into from
Sep 20, 2023
Merged

Refine API wrapper for "Plugins" #114

merged 2 commits into from
Sep 20, 2023

Conversation

amotl
Copy link
Contributor

@amotl amotl commented Sep 20, 2023

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.

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Merging #114 (30a0c40) into main (d99549d) will decrease coverage by 0.31%.
Report is 3 commits behind head on main.
The diff coverage is 47.36%.

@@            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     
Files Changed Coverage Δ
grafana_client/elements/plugin.py 67.44% <47.36%> (-9.49%) ⬇️

📣 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
Copy link
Contributor

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":
Copy link
Contributor

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.

@amotl amotl merged commit 05759df into main Sep 20, 2023
7 checks passed
@amotl amotl deleted the plugins-refine branch September 20, 2023 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants