ITADN

Stabilize OTLP -> Prometheus: add otel_scope_* labels

#5152Openjohannaojeling 创建于 2026-04-27
J
johannaojelingcommented
As part of the effort to stabilize OTLP -> Prometheus conversion, instrumentation scope labels should be added to metric points in the Prometheus exporter, [per spec](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.56.0/specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1). Currently, in `opentelemetry-exporter-prometheus`, metrics are [iterated](https://github.com/open-telemetry/opentelemetry-python/blob/v1.41.1/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py#L231-L234) from `scope_metrics`, but label construction [uses only point attributes](https://github.com/open-telemetry/opentelemetry-python/blob/v1.41.1/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py#L247-L279) and does not include `scope_metrics.scope` fields. As a result, exported metrics currently miss: - `otel_scope_name` - `otel_scope_version` - `otel_scope_schema_url` - `otel_scope_<attr>` labels Related: - https://github.com/open-telemetry/opentelemetry-specification/issues/4918 - https://github.com/open-telemetry/opentelemetry-specification/pull/5052#issuecomment-4321847037
2 条评论