Remove gettime function from new API - #68
Merged
Merged
Conversation
Instead, the new `Prometheus.init` function is used to set a global time function. In the common case (metrics not being collected), the time is always measured as zero, but this doesn't matter. In the second most common case (metrics being collected using prometheus-app.unix), prometheus-app.unix will initialise it. In other cases (e.g. a unikernel that collects metrics), it must be initialised manually. The `collect` function has been renamed to remind users to fix this. The example has been updated to show how to use `Prometheus_lwt` to measure the execution time of a Lwt thread.
Member
|
This looks fine to me; adding the init follows the same pattern as mirage-crypto-rng which needs the global init too. One thing I can't find is any MirageOS unikernel actually using Prometheus right now; are you aware of any? |
Contributor
Author
|
I'm not aware of any unikernels using it. |
Member
|
Nothing for 'prometheus' in mirage-www or https://git.robur.coop/robur/unikernel-repo either, so this is all fine by me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As we're deprecating the old API for time functions, this is the ideal time to get rid of the annoying
gettimeargument. It only exists because we don't want the coreprometheuslibrary to depend onUnix(which would prevent it from being used in unikernels, etc).Instead, the new
Prometheus.initfunction is used to set a global time function.In the common case (metrics not being collected), the time is always measured as zero, but this doesn't matter.
In the second most common case (metrics being collected using prometheus-app.unix), prometheus-app.unix will initialise it.
In other cases (e.g. a unikernel that collects metrics), it must be initialised manually. The
collectfunction has been renamed to remind users to fix this. However, there is no compile-time warning when usingprometheus-appin a unikernel (but trying to read the metrics will raise an exception).The example has been updated to show how to use
Prometheus_lwtto measure the execution time of a Lwt thread.(this is an alternative to #67)