opentelemetry-go
opentelemetry-go copied to clipboard
Support Prometheus native histograms
Problem Statement
We currently drop exponential histograms in the prometheus exporter:
https://github.com/open-telemetry/opentelemetry-go/blob/48fedfa58e35b5f3b08fe54e45cfad441dd82426/exporters/prometheus/exporter.go#L226-L239
Proposed Solution
We should convert them to prometheus native histograms per https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#exponential-histograms
Additional Context
Related to https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33703
This is currently difficult to do because we use prometheus.NewConstHistogram here: https://github.com/open-telemetry/opentelemetry-go/blob/48fedfa58e35b5f3b08fe54e45cfad441dd82426/exporters/prometheus/exporter.go#L256
There is no NewConstNativeHistogram in the prometheus client. We would currently need to implement the prometheus.Metric interface directly, which is a bit more work.
I opened https://github.com/prometheus/client_golang/issues/1617 to see if the prometheus client is interested in adding a const function for this use-case.
This is mostly unblocked after https://github.com/prometheus/client_golang/pull/1654. We just need to wait for a release. Exemplars are not yet supported
I see that https://github.com/prometheus/client_golang/pull/1654 is now merged, is this being worked on somewhere now[issue/pr]?
I started working on this, about to open up a PR. Are you working on this too?
No, not yet, wanted to confirm before starting to work on a PR.
I'll wait for your PR, TIA!
@ajatprabha opened https://github.com/open-telemetry/opentelemetry-go/pull/6421. PTAL.