client_java icon indicating copy to clipboard operation
client_java copied to clipboard

How to use gauge histograms?

Open JnRouvignac opened this issue 3 years ago • 3 comments

OpenMetrics 1.0.0 added the metric types STATE_SET, INFO and GAUGE_HISTOGRAM. I noticed that the classes Enumeration and Info have been added in response (#615), and these correspond to STATE_SET, INFO.

However, I see no new class corresponding to GAUGE_HISTOGRAM. I have looked at the TextFormat class, and IIUC, it handles a gauge histogram as a set of gauges.

Am I right in thinking there will be no GaugeHistogram class? Should we instead create a set of gauges and submit that to prometheus client java?

In short, do you have any documentation or examples showing how to build a gauge histogram?

Thank you

JnRouvignac avatar Aug 18 '22 16:08 JnRouvignac

I have found the following unit test: https://github.com/prometheus/client_java/blob/master/simpleclient_common/src/test/java/io/prometheus/client/exporter/common/TextFormatTest.java#L172-L203

Please feel free to close this issue if you confirm this is how it is supposed to be used.

JnRouvignac avatar Aug 19 '22 08:08 JnRouvignac

:+1: great that you found the unit test. Yes, this is currently the way how to create a GaugeHistogram.

If you have a proposal for a better API for GaugeHistogram, please let me know.

OpenMetrics defines the semantics of GaugeHistogram as follows:

GaugeHistograms measure current distributions. Common examples are how long items have been waiting in a queue, or size of the requests in a queue.

So I don't think an observe() method makes sense, as GaugeHistogram is not intended to track events.

Anyway, if you have a use case that might be relevant for others and a proposal how to support this better, let me know.

fstab avatar Aug 23 '22 21:08 fstab

Gauge.build() without help ,how to fix the case?

wangsonggogo avatar Jul 07 '23 08:07 wangsonggogo