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

Preserve unknown, info, and stateset metric types from prometheus receivers to exporters #32605

Merged
merged 10 commits into from
May 2, 2024

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Apr 22, 2024

Description:

Preserve the original prometheus metric type using metric.metadata, as described in https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#metric-metadata

Prometheus TYPE metadata, if present, MUST be used to determine the OTLP data type, and dictates type-specific conversion rules listed below. Metric families without type metadata follow rules for unknown-typed metrics below. The TYPE metadata MUST also be added to the OTLP metric.metadata under the prometheus.type key (e.g. prometheus.type="unknown").

From https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#gauges-1

An OpenTelemetry Gauge MUST be converted to a Prometheus Unknown-typed metric if the prometheus.type key of metric.metadata is unknown. Otherwise, it MUST be converted to a Prometheus Gauge.

If the aggregation temporality is cumulative and the sum is non-monotonic and the prometheus.type key of metric.metadata is info, it MUST be converted to an OpenMetrics Info metric.
If the aggregation temporality is cumulative and the sum is non-monotonic and the prometheus.type key of metric.metadata is stateset, it MUST be converted to an OpenMetrics StateSet metric.

Link to tracking Issue:

Fixes #16768

Fixes open-telemetry/wg-prometheus#69

Testing:

Updated unit tests.

Note

The prometheus exporter uses the prometheus client library, which does not support info or stateset metric types, so the prometheus exporter only preserves unknown-typed metrics.

@dashpole dashpole requested review from Aneurysm9 and a team as code owners April 22, 2024 19:23
@dashpole dashpole added the enhancement New feature or request label Apr 22, 2024
@dashpole dashpole changed the title Preserve unknown, info, and StateSet metric types from prometheus receivers to exporters Preserve unknown, info, and stateset metric types from prometheus receivers to exporters Apr 22, 2024
@dashpole dashpole added the ready to merge Code review completed; ready to merge by maintainers label Apr 25, 2024
Copy link
Contributor

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@djaglowski djaglowski merged commit fa35c2b into open-telemetry:main May 2, 2024
170 checks passed
@dashpole dashpole deleted the prometheus_type_metadata branch May 2, 2024 15:13
@github-actions github-actions bot added this to the next release milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request exporter/prometheus pkg/translator/prometheus ready to merge Code review completed; ready to merge by maintainers receiver/prometheus Prometheus receiver
Projects
None yet
5 participants