prom-client icon indicating copy to clipboard operation
prom-client copied to clipboard

feat: add support for exemplars

Open samarara opened this issue 3 years ago • 6 comments

With exemplar support coming to Prometheus version 2.26.0 I thought I could start on this. Also addresses #410.

Looking for some direction to see if this the right approach to take. I started with Counter and I'm going to add another function to registry to call depending on register.contentType

samarara avatar Apr 01 '21 19:04 samarara

@siimon @zbjornson I implemented this similar to labels. It publishes metrics in a similar fashion as prometheus uses to parse them. If content-type is application/openmetrics-text the metrics are published with exemplars and the OpenMetrics parser is used in prometheus to parse them.

Let me know if the direction I'm taking is okay. So far it satisfies everything in the OpenMetrics exemplar spec except for the optional timestamp. I'll add that shortly.

samarara avatar Apr 08 '21 01:04 samarara

@zbjornson @siimon any advice on this?

samarara avatar Apr 26 '21 19:04 samarara

@zbjornson @siimon would you be OK with someone else reviewing this MR?

AaronFriel avatar Sep 08 '21 16:09 AaronFriel

@samarara thanks for this MR. i would love to help if you need. We are using jaeger tracing system and really looking forward for this node.js client support

shyimo avatar Sep 20 '21 19:09 shyimo

Sorry for the delay. I need to read up on exemplars and OpenMetrics to review this, but am in favor of adding support. If someone else who's familiar with these concepts wants to help review, that'd be much appreciated!

It would also be helpful if someone can provide links to docs or code for the equivalent functionality in the other Prometheus client libraries (go/java/.NET/etc.).

zbjornson avatar Sep 20 '21 19:09 zbjornson

This MR is a bit out dated as the counter logic has changed since I authored this. Any help would be greatly appreciated. Here is the spec: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#exemplars

For the Java client it's implemented for both counters and histograms: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#exemplars-1 implementation: https://github.com/prometheus/client_java/blob/7a29af04821cd51592c45ce4682c3132372f4c5d/simpleclient/src/main/java/io/prometheus/client/exemplars/Exemplar.java#L10

samarara avatar Sep 20 '21 20:09 samarara

This landed in #544 I believe - sorry about the radio silence!

SimenB avatar Oct 02 '23 08:10 SimenB