prometheus-cpp icon indicating copy to clipboard operation
prometheus-cpp copied to clipboard

Set callback for Gauge

Open ekpdt opened this issue 3 years ago • 4 comments

I'd like to start a discussion about supporting gauges whose value is determined at scrape time by evaluating a function. This functionality is essential when proxying a value from code that cannot be (easily) instrumented (for example, reporting the system load) or as a convenience when explicit modification of a gauge might be a nuisance (for example, instrumenting the length of a queue without requiring a proxy or facade object).

The Go, Java, and Python official clients all offer functionality like this.

Any implementation in C++ would encounter an obvious tension with object lifetimes, but I think we can just leave that to users to decide what to do.

The no-action alternative here is for users to implement their own Collectables.

ekpdt avatar Oct 11 '21 20:10 ekpdt

Any news regarding such functionality? We also are interested in it. @gjasny maybe you can provide some feedback.

zamazan4ik avatar Nov 03 '21 15:11 zamazan4ik

I'll work on improving prometheus-cpp during the next weeks. I'll consider adding such a callback if it integrated nicely into existing architecture.

gjasny avatar Nov 16 '21 08:11 gjasny

any update on this? or do we have any workaround to achieve this for now?

VenkateswaranJ avatar May 24 '22 15:05 VenkateswaranJ

I guess @gjasny knows somehting about the current status.

zamazan4ik avatar May 24 '22 15:05 zamazan4ik