Description
Problem
The Prometheus and OpenMetrics Compatibility Spec says:
An OpenTelemetry Exponential Histogram with a cumulative aggregation temporality MUST be converted to a Prometheus Native Histogram.
I understand this is currently not implemented in the Prometheus exporter in the OTel Java SDK: Exponential histograms are dropped.
I would like to add OpenTelemetry Exponential Histogram to Prometheus Native Histogram conversion. As Prometheus Native histograms can only be exposed in Prometheus Protobuf format, I would also add support for Prometheus protobuf as an additional exposition format.
However, before I start working on it, I'm creating this issue. Please let me know what you think.
Proposed Solution
I'm one of the maintainers of the Prometheus Java client library, and we recently released version 1.0.0. The Prometheus Java client library is owned by the Prometheus team under CNCF governance.
The new architecture of the 1.0.0 release separates the implementation of the Prometheus data model and the Prometheus metrics library, as described on https://prometheus.github.io/client_java/internals/model/:
prometheus-metrics-core
is the metrics library. There's no need to add a dependency to this module to the Prometheus SDK.prometheus-metrics-model
are read-only immutable Prometheus metric snapshots produced during scraping.exposition formats
convert the snapshots into different exposition formats, like Prometheus text format, OpenMetrics text format, or Prometheus protobuf format.
My proposal is to refactor OpenTelemetry Java's Prometheus exporter to produce Snapshots as defined in prometheus-metrics-model
, and to use Prometheus exposition format modules to convert these snapshots to Prometheus Text format, OpenMetrics format, and Prometheus Protobuf format depending on the Accept
header in the scrape request.
I'm happy to maintain the Prometheus exporter long term if you need a maintainer.
The immediate benefit is support for Native histograms.
However, there's also a long-term benefit: Prometheus exposition formats are currently in flux, there is a decision to add a new OpenMetrics format, but that isn't specified yet. However, if the OpenTelemetry Java SDK uses the exposition format modules from the Prometheus Java client library, adding support for future Prometheus exposition formats will be a trivial change, because you can just use the upstream dependency from the Prometheus project.
Let me know what you think. I'm happy to create a PR if you think this is a good idea.