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

feat: wrap github api updates with metric counter #5

Merged
merged 3 commits into from
Nov 28, 2023
Merged

Conversation

StevenPJ
Copy link

@StevenPJ StevenPJ commented Nov 28, 2023

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

@StevenPJ StevenPJ requested a review from a team as a code owner November 28, 2023 08:52
@StevenPJ StevenPJ merged commit b83b17a into master Nov 28, 2023
1 check passed
@StevenPJ StevenPJ deleted the update_metrics branch November 28, 2023 09:57
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