opentelemetry-go icon indicating copy to clipboard operation
opentelemetry-go copied to clipboard

Support Prometheus native histograms

Open dashpole opened this issue 1 year ago • 6 comments
trafficstars

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.

dashpole avatar Sep 04 '24 15:09 dashpole

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.

dashpole avatar Sep 04 '24 15:09 dashpole

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

dashpole avatar Nov 14 '24 14:11 dashpole

I see that https://github.com/prometheus/client_golang/pull/1654 is now merged, is this being worked on somewhere now[issue/pr]?

ajatprabha avatar Mar 06 '25 09:03 ajatprabha

I started working on this, about to open up a PR. Are you working on this too?

GiedriusS avatar Mar 06 '25 09:03 GiedriusS

No, not yet, wanted to confirm before starting to work on a PR.

I'll wait for your PR, TIA!

ajatprabha avatar Mar 06 '25 10:03 ajatprabha

@ajatprabha opened https://github.com/open-telemetry/opentelemetry-go/pull/6421. PTAL.

GiedriusS avatar Mar 07 '25 10:03 GiedriusS