Skip to content

Support Prometheus native histograms #5777

Open
@dashpole

Description

@dashpole

Problem Statement

We currently drop exponential histograms in the prometheus exporter:

switch v := m.Data.(type) {
case metricdata.Histogram[int64]:
addHistogramMetric(ch, v, m, keys, values, name, c.resourceKeyVals)
case metricdata.Histogram[float64]:
addHistogramMetric(ch, v, m, keys, values, name, c.resourceKeyVals)
case metricdata.Sum[int64]:
addSumMetric(ch, v, m, keys, values, name, c.resourceKeyVals)
case metricdata.Sum[float64]:
addSumMetric(ch, v, m, keys, values, name, c.resourceKeyVals)
case metricdata.Gauge[int64]:
addGaugeMetric(ch, v, m, keys, values, name, c.resourceKeyVals)
case metricdata.Gauge[float64]:
addGaugeMetric(ch, v, m, keys, values, name, c.resourceKeyVals)
}

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 open-telemetry/opentelemetry-collector-contrib#33703

This is currently difficult to do because we use prometheus.NewConstHistogram here:

m, err := prometheus.NewConstHistogram(desc, dp.Count, float64(dp.Sum), buckets, values...)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions