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

Callback-based Gauge? #171

Closed
plainlystated opened this issue Dec 20, 2019 · 2 comments
Closed

Callback-based Gauge? #171

plainlystated opened this issue Dec 20, 2019 · 2 comments

Comments

@plainlystated
Copy link

Is there any way to implement a callback-based gauge? This would be very useful for metrics that aren't related to the threads or processes of the server. For example, the docs mention a gauge for temperature:

gauge = Prometheus::Client::Gauge.new(:room_temperature_celsius, docstring: '...', labels: [:room])

This requires that there is some mechanism that continually updates the gauge via gauge.set, and hopefully the cadence of this mechanism matches the cadence of the scrape. It would be really nice to instead specify a callback and have the value calculated as needed.

This is how the python library works, which is great:

d = Gauge('room_temperature_celsius', 'Temp of room', ['room'])
d.labels('Room 1').set_function(lambda: ...))
@dmagliola
Copy link
Collaborator

Hello,
Thank you for opening the issue.
The solution for this is Custom Collectors, which we're hoping to implement soon.
We're tracking that discussion on issue #90

I'm closing this issue as a duplicate of that one. Wir keep any updates to the other issue.

Thank you!

@plainlystated
Copy link
Author

Great, thanks for the update. I'll keep an eye on that ticket.

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