Skip to content

Does Timer functionality exist in Prometheus.Client? #176

Closed Answered by sanych-sun
cscoon asked this question in Q&A
Discussion options

You must be logged in to vote

We have similar functionality: ObserveDuration and ObserveDurationAsync extension methods that could be used for Histogram and Summary.

For example:

await myHistogram.WithLabels("a", "b").ObserveDurationAsync(async () => {
    await Task.Delay(1000);
});

The benefit of this approach - it's a determined moment of the observation (unlike nonintuitive at least for me observation in timer dispose).

I hope this helps =)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sanych-sun
Comment options

@cscoon
Comment options

Answer selected by cscoon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants