Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Prometheus native histograms #5777

Open
dashpole opened this issue Sep 4, 2024 · 2 comments
Open

Support Prometheus native histograms #5777

dashpole opened this issue Sep 4, 2024 · 2 comments
Labels
enhancement New feature or request pkg:exporter:prometheus Related to the Prometheus exporter package

Comments

@dashpole
Copy link
Contributor

dashpole commented Sep 4, 2024

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.

@dashpole dashpole added enhancement New feature or request pkg:exporter:prometheus Related to the Prometheus exporter package labels Sep 4, 2024
@dashpole
Copy link
Contributor Author

dashpole commented Sep 4, 2024

I opened prometheus/client_golang#1617 to see if the prometheus client is interested in adding a const function for this use-case.

@dashpole
Copy link
Contributor Author

This is mostly unblocked after prometheus/client_golang#1654. We just need to wait for a release. Exemplars are not yet supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg:exporter:prometheus Related to the Prometheus exporter package
Projects
None yet
Development

No branches or pull requests

1 participant