weaveworks / promjs

Other
151 stars 24 forks source link

Best practice for listening for changes to the metrics registry #37

Open hmillison opened 3 years ago

hmillison commented 3 years ago

Hey! Great work with this library, i'm currently working on using it to start instrumenting my org's app.

I'm curious to hear what the best approach is for listening to changes to counters, histograms, etc created by a registry so you know to send an update to your Prometheus Gateway.

I was expecting that maybe the registry would expose some sort of onChange listener you could use to trigger new requests to send the latest metrics to your backend.

For now i'm just checking the registry.metrics() output for changes on an interval and using that to send the latest metrics to the backend. Curious to know if anyone has a recommended way to do this?

SergiuB commented 3 years ago

Instead of directly using the histogram API, I've created a wrapper over it that notifies listeners when observe is called.