How to refresh some metrics before responding to a metrics call #802
-
I am looking for way to update some metrics before a call to the metrics endpoint is made. Since I am forwarding some stats from an XML document, I was hoping to only parse the XML file if a request to the metrics endpoint is made. To have fresh metrics and saving some CPU cycle. This would also prevent having an extra thread looping over and over to refresh the metrics. Ideally I would see a hook in the metrics endpoint handler where I could pass a callable that do the stats forwarding. I could also extend the existing metrics handler but I was hoping to get some tips from the experts. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello, you will want to use a custom collector for this use case. The |
Beta Was this translation helpful? Give feedback.
Hello, you will want to use a custom collector for this use case. The
collect
method will only be ran when your metrics are scraped and you will be sure to have up to date values and no need for a background thread.