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

Example of a pull strategy #84

Open
yterradas opened this issue Dec 15, 2020 · 2 comments
Open

Example of a pull strategy #84

yterradas opened this issue Dec 15, 2020 · 2 comments

Comments

@yterradas
Copy link

hi,

i have been looking through the documentation and examples but i cannot find a way to output the metrics based on a pull strategy. since i am writing a library what i am looking for is a way to iterate over list of metrics exposing their values to the hosting app. is there a way to achieve so?

thank you in advance

@fralalonde
Copy link
Owner

Hello! It certainly is possible to do pull metrics. None of the examples show you how but it's a use case that should be covered.

One plan would be to use an AtomicBucket to accumulate stats. Assuming that you want to do answer HTTP requests, the "pull" part would print the bucket's content to the HTTP response using bucket.flush_to(). The specifics will depend on the HTTP lib that you're using. See the bucket example for a rough starting point of this idea.

The plan is to eventually have a Prometheus pull implementation, which you could have based your code upon. If you care to share your code back, I'll be happy to integrate it with the examples.

@yterradas
Copy link
Author

@fralalonde
thank you for the response.
i am writing a FFI library so i dont have a HTTP response to write to. instead i need to provide a metric_name metric_value (or some other format). the example you provided puts me a little further than i was before in the sense that stats_summary is very close to what i need but i am left with figuring out a SCOPE that will give the metrics on command. i am not knowledgeable enough of Rust to understand what an impl would look like, please educate me if you can.
alternatively the original path i had in mind was looping through each of the metrics, printing out metric_name metric_value. understandably flushing would accomplish the same in a thread-safe way. ultimately i couldnt find a way to get the metric's value so i need some guidance as to how either get the metric's value or to define a scope that gets me data in a string i can pass along.

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

No branches or pull requests

2 participants