From 664fca9787f7323aff1559033a0d1f5fe10fe019 Mon Sep 17 00:00:00 2001 From: Robert Pajak Date: Tue, 13 May 2025 12:54:46 +0200 Subject: [PATCH 1/4] prometheus: handle scheme URL and scope attributes --- CHANGELOG.md | 9 ++++ spec-compliance-matrix.md | 4 +- .../prometheus_and_openmetrics.md | 41 ++++++++----------- .../metrics/sdk_exporters/prometheus.md | 4 +- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b7c769d787..78020019c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,15 @@ release. ### Metrics +- Prometheus receiver can expect `otel_scope_schema_url` and `otel_scope_[attribute]` labels on all metrics. + ([#???](https://github.com/open-telemetry/opentelemetry-specification/pull/???)) +- Prometheus receiver no longer expects `otel_scope_info` metric. + ([#???](https://github.com/open-telemetry/opentelemetry-specification/pull/???)) +- Prometheus exporter adds `otel_scope_schema_url` and `otel_scope_[attribute]` labels on all metrics. + ([#???](https://github.com/open-telemetry/opentelemetry-specification/pull/???)) +- Prometheus exporter no longer exports `otel_scope_info` metric. + ([#???](https://github.com/open-telemetry/opentelemetry-specification/pull/???)) + ### Logs ### Baggage diff --git a/spec-compliance-matrix.md b/spec-compliance-matrix.md index c15f1b0c25e..fb0d100db90 100644 --- a/spec-compliance-matrix.md +++ b/spec-compliance-matrix.md @@ -355,8 +355,8 @@ Disclaimer: Declarative configuration is currently in Development status - work | [HELP Metadata](specification/compatibility/prometheus_and_openmetrics.md#metric-metadata-1) | | + | + | + | + | - | - | - | + | + | + | + | | [TYPE Metadata](specification/compatibility/prometheus_and_openmetrics.md#metric-metadata-1) | | + | + | + | + | - | - | - | + | + | + | + | | [otel_scope_name and otel_scope_version labels on all Metrics](specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1) | | + | + | - | - | - | - | - | + | - | - | - | -| [otel_scope_info metric](specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1) | X | + | + | - | - | - | - | - | + | - | - | - | -| [otel_scope_info and labels can be disabled](specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1) | X | + | - | - | - | - | - | - | + | - | - | - | +| [otel_scope_[attribute] labels on all Metrics](specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1) | | + | - | - | - | - | - | - | - | - | - | - | +| [otel_scope labels can be disabled](specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1) | X | + | - | - | - | - | - | - | + | - | - | - | | [Gauges become Prometheus Gauges](specification/compatibility/prometheus_and_openmetrics.md#gauges-1) | | + | + | + | + | - | - | - | + | + | + | - | | [Cumulative Monotonic Sums become Prometheus Counters](specification/compatibility/prometheus_and_openmetrics.md#sums) | | + | + | + | + | - | - | - | + | + | + | + | | [Prometheus Counters have _total suffix by default](specification/compatibility/prometheus_and_openmetrics.md#sums) | | + | + | + | + | - | - | - | + | - | - | - | diff --git a/specification/compatibility/prometheus_and_openmetrics.md b/specification/compatibility/prometheus_and_openmetrics.md index 9fd8df9a912..6c720f8af6e 100644 --- a/specification/compatibility/prometheus_and_openmetrics.md +++ b/specification/compatibility/prometheus_and_openmetrics.md @@ -166,19 +166,14 @@ exemplar as attributes. ### Instrumentation Scope -The `otel_scope_name` and `otel_scope_version` lables, if present, SHOULD be -dropped from all metric points and used as the Instrumentation Scope name and -version respectively. All `otel_scope_info` metrics present in a batch -of metrics SHOULD be dropped from the incoming scrape. Labels on -`otel_scope_info` metric points other than `otel_scope_name` and -`otel_scope_version`, MUST be added as scope attributes to the scope with the -matching name and version. For example, the OpenMetrics text-formatted metrics: +Labels with `otel_scope_` prefix MUST be dropped from all metric points +and used as the Instrumentation Scope name (`otel_scope_name`), +version (`otel_scope_version`), schema URL (`otel_scope_schema_url`), +attributes (`otel_scope_[attribute]`). ``` -# TYPE otel_scope_info info -otel_scope_info{otel_scope_name="go.opentelemetry.io.contrib.instrumentation.net.http.otelhttp",otel_scope_version="v0.24.0",library_mascot="bear"} 1 # TYPE http_server_duration counter -http_server_duration{otel_scope_name="go.opentelemetry.io.contrib.instrumentation.net.http.otelhttp",otel_scope_version="v0.24.0"...} 1 +http_server_duration{otel_scope_name="go.opentelemetry.io.contrib.instrumentation.net.http.otelhttp",otel_scope_schema_url="https://opentelemetry.io/schemas/1.31.0",otel_scope_version="v0.24.0",otel_scope_library_mascot="gopher"...} 1 ``` becomes: @@ -190,7 +185,8 @@ scope_metrics: name: go.opentelemetry.io.contrib.instrumentation.net.http.otelhttp version: v0.24.0 attributes: - library_mascot: bear + library_mascot: gopher + schema_url: https://opentelemetry.io/schemas/1.31.0 metrics: - name: http_server_duration data: @@ -199,7 +195,7 @@ scope_metrics: - value: 1 ``` -Metrics which do not have an `otel_scope_name` or `otel_scope_version` label +Metrics which do not have any label with `otel_scope_` prefix MUST be assigned an instrumentation scope identifying the entity performing the translation from Prometheus to OpenTelemetry (e.g. the collector's prometheus receiver). @@ -280,19 +276,16 @@ It also dictates type-specific conversion rules listed below. ### Instrumentation Scope -Prometheus exporters SHOULD generate an [Info](https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#info)-typed -metric named `otel_scope_info` for each Instrumentation Scope with non-empty -scope attributes. If present, Instrumentation Scope `name` and `version` MUST -be added as `otel_scope_name` and `otel_scope_version` labels. Scope attributes -MUST also be added as labels following the rules described in the -[`Metric Attributes`](#metric-attributes) section below. +Prometheus exporters MUST by default add +the scope name as the `otel_scope_name` label, +the scope version as the `otel_scope_version` label, +the scope schema URL as the `otel_scope_schema_url` label, +the scope attribbutes as labels with `otel_scope_` prefix and following the rules +described in the [`Metric Attributes`](#metric-attributes) section below, +on all metric points, based on the scope the original data point was nested in. -Prometheus exporters MUST add the scope name as the `otel_scope_name` label and -the scope version as the `otel_scope_version` label on all metric points by -default, based on the scope the original data point was nested in. - -Prometheus exporters SHOULD provide a configuration option to disable the -`otel_scope_info` metric and `otel_scope_` labels. +Prometheus exporters MAY provide a configuration option to disable +`otel_scope_` labels. ### Gauges diff --git a/specification/metrics/sdk_exporters/prometheus.md b/specification/metrics/sdk_exporters/prometheus.md index 771e3ea8ac4..5507303f7bf 100644 --- a/specification/metrics/sdk_exporters/prometheus.md +++ b/specification/metrics/sdk_exporters/prometheus.md @@ -69,8 +69,8 @@ or UNIT metadata. The option MAY be named `without_units`, and MUST be `false` b A Prometheus Exporter MAY support a configuration option to produce metrics without a [type suffix](../../compatibility/prometheus_and_openmetrics.md#metric-metadata). The option MAY be named `without_type_suffix`, and MUST be `false` by default. -A Prometheus Exporter MAY support a configuration option to produce metrics without a [scope info](../../compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1) -metric, or scope labels. The option MAY be named `without_scope_info`, and MUST be `false` by default. +A Prometheus Exporter MAY support a configuration option to produce metrics without [scope labels](../../compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1). +The option MAY be named `without_scope_info`, and MUST be `false` by default. A Prometheus Exporter MAY support a configuration option to produce metrics without a [target info](../../compatibility/prometheus_and_openmetrics.md#resource-attributes-1) metric. The option MAY be named `without_target_info`, and MUST be `false` by default. From d0655017b7d415948b0d2b74735f9c3853d6fdea Mon Sep 17 00:00:00 2001 From: Robert Pajak Date: Tue, 13 May 2025 12:55:42 +0200 Subject: [PATCH 2/4] Update changelog --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78020019c51..854b1670aab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,13 +17,13 @@ release. ### Metrics - Prometheus receiver can expect `otel_scope_schema_url` and `otel_scope_[attribute]` labels on all metrics. - ([#???](https://github.com/open-telemetry/opentelemetry-specification/pull/???)) + ([#4505](https://github.com/open-telemetry/opentelemetry-specification/pull/4505)) - Prometheus receiver no longer expects `otel_scope_info` metric. - ([#???](https://github.com/open-telemetry/opentelemetry-specification/pull/???)) + ([#4505](https://github.com/open-telemetry/opentelemetry-specification/pull/4505)) - Prometheus exporter adds `otel_scope_schema_url` and `otel_scope_[attribute]` labels on all metrics. - ([#???](https://github.com/open-telemetry/opentelemetry-specification/pull/???)) + ([#4505](https://github.com/open-telemetry/opentelemetry-specification/pull/4505)) - Prometheus exporter no longer exports `otel_scope_info` metric. - ([#???](https://github.com/open-telemetry/opentelemetry-specification/pull/???)) + ([#4505](https://github.com/open-telemetry/opentelemetry-specification/pull/4505)) ### Logs From a3951abc541d4748c40936a7d79e4c4d293a94b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Tue, 13 May 2025 14:11:01 +0200 Subject: [PATCH 3/4] Update specification/compatibility/prometheus_and_openmetrics.md Co-authored-by: Jade Guiton --- specification/compatibility/prometheus_and_openmetrics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/compatibility/prometheus_and_openmetrics.md b/specification/compatibility/prometheus_and_openmetrics.md index 6c720f8af6e..dfbd0057814 100644 --- a/specification/compatibility/prometheus_and_openmetrics.md +++ b/specification/compatibility/prometheus_and_openmetrics.md @@ -280,7 +280,7 @@ Prometheus exporters MUST by default add the scope name as the `otel_scope_name` label, the scope version as the `otel_scope_version` label, the scope schema URL as the `otel_scope_schema_url` label, -the scope attribbutes as labels with `otel_scope_` prefix and following the rules +the scope attributes as labels with `otel_scope_` prefix and following the rules described in the [`Metric Attributes`](#metric-attributes) section below, on all metric points, based on the scope the original data point was nested in. From d8d194f45e4d6da99f7da0b022f750f85e1f17a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Fri, 23 May 2025 09:58:40 +0200 Subject: [PATCH 4/4] Remove redunant exporter config spec --- specification/compatibility/prometheus_and_openmetrics.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/specification/compatibility/prometheus_and_openmetrics.md b/specification/compatibility/prometheus_and_openmetrics.md index dfbd0057814..8aa227a8f5e 100644 --- a/specification/compatibility/prometheus_and_openmetrics.md +++ b/specification/compatibility/prometheus_and_openmetrics.md @@ -284,9 +284,6 @@ the scope attributes as labels with `otel_scope_` prefix and following the rules described in the [`Metric Attributes`](#metric-attributes) section below, on all metric points, based on the scope the original data point was nested in. -Prometheus exporters MAY provide a configuration option to disable -`otel_scope_` labels. - ### Gauges An [OpenTelemetry Gauge](../metrics/data-model.md#gauge) MUST be converted to