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

Collectors can now be async #304

Merged
merged 2 commits into from
Jan 29, 2021
Merged

Collectors can now be async #304

merged 2 commits into from
Jan 29, 2021

Conversation

Half-Shot
Copy link
Contributor

Fixes #139

@Half-Shot Half-Shot requested a review from a team January 25, 2021 12:46
/**
* Fetch metrics from all configured collectors
*/
public async refresh () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does refresh need a lock (or wrapper returning an ongoing promise) so it cannot get run more than once at a time?

Copy link
Contributor Author

@Half-Shot Half-Shot Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're okay in this case. The caller should manage that, whether that be a bridge or the application requesting the /metrics endpoint. I don't think a race will cause any serious problems as you're just asking it to refresh metrics , which should be RO functions.

@jaller94
Copy link
Contributor

Back and forth in my head:
You seem to be pretty sure that all of these promises are fulfilled within seconds.
I'm a bit worried that a bridge calls long-running (or never-ending) functions on registration or refreshing.
Then again, that would be a (performance) bug in the bridge..
Making this async is still be an improvement, because other things can run in between.

@Half-Shot
Copy link
Contributor Author

Half-Shot commented Jan 28, 2021

Then again, that would be a (performance) bug in the bridge..
Making this async is still be an improvement, because other things can run in between.

This was my thinking. A bridge should ensure that collector functions do not block for serious amounts of time, and if they do then the /metrics endpoint should show that clearly by taking longer rather than us trying to make the endpoint return faster but with potentially the wrong values.

Copy link
Contributor

@jaller94 jaller94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. 👍

@Half-Shot Half-Shot merged commit ee19602 into develop Jan 29, 2021
@Half-Shot Half-Shot deleted the hs/async-metrics branch May 2, 2023 16:06
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.

registerBridgeGauges should call collectorFunc asyncronously
2 participants