feat: wrap github api updates with metric counter #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
the plugins/settings tend to all handle updates different, sometimes catching errors using the promises, sometimes propagating, sometimes catching with a try/catch block. This lack of consistency makes it very hard to create a clean metric abstraction layer.
As an alternative, have created a sort of higher order function for wrapping plugin github api calls with a metric. We can decorate all the github update calls and it will increment a counter based on the call result and propagate any errors up the stack.
Not ideal, but cognitively fairly simple, and the changes are just around octokits, which hopefully are unlikely to change (the params might but we dont interfere with that). We pass in the plugins so we can refer to their name and access the repoName that is part of the instance.
Not sure how best to test this, as loads of the tests fail and tried fixing them quickly but no luck. I have tested locally with our safe-settings local dev setup in k8s and seen the metrics perform better. Some functionality is only available on orgs so will need some additional testing in sbx