prom-client
prom-client copied to clipboard
feat: add support for exemplars
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
@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.
@zbjornson @siimon any advice on this?
@zbjornson @siimon would you be OK with someone else reviewing this MR?
@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
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.).
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
This landed in #544 I believe - sorry about the radio silence!