From 1a7e5d27796a2f48936fcfe1f8ac3c539f3cccdb Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Mon, 13 Nov 2023 16:55:01 +0200 Subject: [PATCH 01/15] Allowing exporters (e.g. Prometheus exporter) to add the resource attributes to each exported metric attributes --- specification/metrics/sdk.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/specification/metrics/sdk.md b/specification/metrics/sdk.md index 0ac9ad9f29e..6ae97cbe254 100644 --- a/specification/metrics/sdk.md +++ b/specification/metrics/sdk.md @@ -1296,6 +1296,9 @@ can run at different schedule, for example: * Exporter D is a pull exporter which reacts to another scraper over a named pipe. +Exporters MAY offer configuration to add resource attributes as metric attributes. +By default, it MUST not add any resource attributes as metric attributes. + ### Push Metric Exporter Push Metric Exporter sends metric data it receives from a paired From afe639f789a6636d89ab75226816f7b689a356af Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Mon, 13 Nov 2023 19:04:32 +0200 Subject: [PATCH 02/15] Moved to Prometheus exporter --- specification/metrics/sdk.md | 3 --- specification/metrics/sdk_exporters/prometheus.md | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/metrics/sdk.md b/specification/metrics/sdk.md index 6ae97cbe254..0ac9ad9f29e 100644 --- a/specification/metrics/sdk.md +++ b/specification/metrics/sdk.md @@ -1296,9 +1296,6 @@ can run at different schedule, for example: * Exporter D is a pull exporter which reacts to another scraper over a named pipe. -Exporters MAY offer configuration to add resource attributes as metric attributes. -By default, it MUST not add any resource attributes as metric attributes. - ### Push Metric Exporter Push Metric Exporter sends metric data it receives from a paired diff --git a/specification/metrics/sdk_exporters/prometheus.md b/specification/metrics/sdk_exporters/prometheus.md index 8470a55694d..a6e133efb5e 100644 --- a/specification/metrics/sdk_exporters/prometheus.md +++ b/specification/metrics/sdk_exporters/prometheus.md @@ -25,3 +25,6 @@ A Prometheus Exporter MAY support [OpenMetrics Text Format](https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#openmetrics-text-format), including the [Exemplars](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#exemplars). + +A Prometheus Exporter MAY offer configuration to add resource attributes as metric attributes. +By default, it MUST not add any resource attributes as metric attributes. From 1937a614add8846139afa85c886148d7bafc5ddc Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Mon, 13 Nov 2023 22:52:54 +0200 Subject: [PATCH 03/15] fixed not --- specification/metrics/sdk_exporters/prometheus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/metrics/sdk_exporters/prometheus.md b/specification/metrics/sdk_exporters/prometheus.md index a6e133efb5e..13c8b2e7758 100644 --- a/specification/metrics/sdk_exporters/prometheus.md +++ b/specification/metrics/sdk_exporters/prometheus.md @@ -27,4 +27,4 @@ including the [Exemplars](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#exemplars). A Prometheus Exporter MAY offer configuration to add resource attributes as metric attributes. -By default, it MUST not add any resource attributes as metric attributes. +By default, it MUST NOT add any resource attributes as metric attributes. From 917637331b2fb78c42baddc1246adb333de8533d Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Mon, 13 Nov 2023 22:55:33 +0200 Subject: [PATCH 04/15] Updated CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5debda72f5f..b5fb60513f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ release. ### Traces ### Metrics +- Add optional configuration for Prometheus exporters to promote resource attributes to metric attributes + ([#3761](https://github.com/open-telemetry/opentelemetry-specification/pull/3761)) ### Logs From c2d9f6574cd98398775b66b1120858394afe7157 Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Mon, 13 Nov 2023 22:56:41 +0200 Subject: [PATCH 05/15] Fixed lint error --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5fb60513f1..303a71131c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ release. ### Traces ### Metrics + - Add optional configuration for Prometheus exporters to promote resource attributes to metric attributes ([#3761](https://github.com/open-telemetry/opentelemetry-specification/pull/3761)) From 2b2c6be03300b21f4ec1beed2e91d5f17a3fcbf8 Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Mon, 13 Nov 2023 22:57:36 +0200 Subject: [PATCH 06/15] Fixed lint error 2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 303a71131c7..6fabdcc303e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ release. ### Metrics -- Add optional configuration for Prometheus exporters to promote resource attributes to metric attributes +- Add optional configuration for Prometheus exporters to promote resource attributes to metric attributes ([#3761](https://github.com/open-telemetry/opentelemetry-specification/pull/3761)) ### Logs From cd3428ffc54612aafc7176eafd264609957c01cc Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Tue, 14 Nov 2023 15:15:41 +0200 Subject: [PATCH 07/15] Update specification/metrics/sdk_exporters/prometheus.md Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com> --- specification/metrics/sdk_exporters/prometheus.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specification/metrics/sdk_exporters/prometheus.md b/specification/metrics/sdk_exporters/prometheus.md index 13c8b2e7758..58ffda620bc 100644 --- a/specification/metrics/sdk_exporters/prometheus.md +++ b/specification/metrics/sdk_exporters/prometheus.md @@ -28,3 +28,4 @@ including the A Prometheus Exporter MAY offer configuration to add resource attributes as metric attributes. By default, it MUST NOT add any resource attributes as metric attributes. + From 4595abe6c13200f68d58d51318b247f74100e5bb Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Tue, 14 Nov 2023 15:29:43 +0200 Subject: [PATCH 08/15] Fix lint errors --- specification/metrics/sdk_exporters/prometheus.md | 1 - 1 file changed, 1 deletion(-) diff --git a/specification/metrics/sdk_exporters/prometheus.md b/specification/metrics/sdk_exporters/prometheus.md index 58ffda620bc..13c8b2e7758 100644 --- a/specification/metrics/sdk_exporters/prometheus.md +++ b/specification/metrics/sdk_exporters/prometheus.md @@ -28,4 +28,3 @@ including the A Prometheus Exporter MAY offer configuration to add resource attributes as metric attributes. By default, it MUST NOT add any resource attributes as metric attributes. - From 936c9f22ff2446cacfabf7246341b16d006df03c Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Wed, 15 Nov 2023 11:51:14 +0200 Subject: [PATCH 09/15] PR Fixes --- specification/metrics/sdk_exporters/prometheus.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/specification/metrics/sdk_exporters/prometheus.md b/specification/metrics/sdk_exporters/prometheus.md index 13c8b2e7758..c7c56ef37fa 100644 --- a/specification/metrics/sdk_exporters/prometheus.md +++ b/specification/metrics/sdk_exporters/prometheus.md @@ -28,3 +28,6 @@ including the A Prometheus Exporter MAY offer configuration to add resource attributes as metric attributes. By default, it MUST NOT add any resource attributes as metric attributes. +The configuration SHOULD allow the user to select which resource attributes to copy (e.g. +include / exclude or regular expression based). Copied Resource attributes MUST NOT be +excluded from target_info, if target_info is enabled. From 6a53816f66ff7a824419229b10c2d6fdf497a61f Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Wed, 15 Nov 2023 12:05:43 +0200 Subject: [PATCH 10/15] Fixed compatability doc --- specification/compatibility/prometheus_and_openmetrics.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specification/compatibility/prometheus_and_openmetrics.md b/specification/compatibility/prometheus_and_openmetrics.md index ecb74fc73dd..92997bc5f1f 100644 --- a/specification/compatibility/prometheus_and_openmetrics.md +++ b/specification/compatibility/prometheus_and_openmetrics.md @@ -386,10 +386,10 @@ OpenMetrics exemplar unless they would exceed the OpenMetrics In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to a single [`target_info` metric](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems) if the resource is not [empty](../resource/sdk.md#the-empty-resource); -otherwise, they MUST be dropped, and MUST NOT be attached as labels to other -metric families. The target_info metric MUST be an info-typed metric whose -labels MUST include the resource attributes, and MUST NOT include any other -labels. There MUST be at most one target_info metric exposed on an SDK +The resource attributes MAY be copied as labels of exported metric families, +as defined by an SDK configuration. The target_info metric MUST be an info-typed +metric whose labels MUST include the resource attributes, and MUST NOT include +any other labels. There MUST be at most one target_info metric exposed on an SDK Prometheus endpoint. In the Collector's Prometheus pull and push (remote-write) exporters, it is From c7546c2a0e4553328dcdbbf3408159eb81496d05 Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Tue, 21 Nov 2023 11:18:02 +0200 Subject: [PATCH 11/15] Update specification/compatibility/prometheus_and_openmetrics.md Co-authored-by: David Ashpole --- specification/compatibility/prometheus_and_openmetrics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/compatibility/prometheus_and_openmetrics.md b/specification/compatibility/prometheus_and_openmetrics.md index 92997bc5f1f..fa91b0149a2 100644 --- a/specification/compatibility/prometheus_and_openmetrics.md +++ b/specification/compatibility/prometheus_and_openmetrics.md @@ -386,8 +386,8 @@ OpenMetrics exemplar unless they would exceed the OpenMetrics In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to a single [`target_info` metric](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems) if the resource is not [empty](../resource/sdk.md#the-empty-resource); -The resource attributes MAY be copied as labels of exported metric families, -as defined by an SDK configuration. The target_info metric MUST be an info-typed +The resource attributes MAY be copied to labels of exported metric families, +if required by the exporter configuration, or MUST be dropped. The target_info metric MUST be an info-typed metric whose labels MUST include the resource attributes, and MUST NOT include any other labels. There MUST be at most one target_info metric exposed on an SDK Prometheus endpoint. From e7cfcba3b32c3ad2c993f064ee9144ec13267b05 Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Wed, 22 Nov 2023 11:34:43 +0200 Subject: [PATCH 12/15] lint fixes --- specification/compatibility/prometheus_and_openmetrics.md | 8 ++++---- specification/metrics/sdk_exporters/prometheus.md | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/specification/compatibility/prometheus_and_openmetrics.md b/specification/compatibility/prometheus_and_openmetrics.md index fa91b0149a2..bfe163ede49 100644 --- a/specification/compatibility/prometheus_and_openmetrics.md +++ b/specification/compatibility/prometheus_and_openmetrics.md @@ -386,10 +386,10 @@ OpenMetrics exemplar unless they would exceed the OpenMetrics In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to a single [`target_info` metric](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems) if the resource is not [empty](../resource/sdk.md#the-empty-resource); -The resource attributes MAY be copied to labels of exported metric families, -if required by the exporter configuration, or MUST be dropped. The target_info metric MUST be an info-typed -metric whose labels MUST include the resource attributes, and MUST NOT include -any other labels. There MUST be at most one target_info metric exposed on an SDK +The resource attributes MAY be copied to labels of exported metric families, +if required by the exporter configuration, or MUST be dropped. The target_info metric MUST be an info-typed +metric whose labels MUST include the resource attributes, and MUST NOT include +any other labels. There MUST be at most one target_info metric exposed on an SDK Prometheus endpoint. In the Collector's Prometheus pull and push (remote-write) exporters, it is diff --git a/specification/metrics/sdk_exporters/prometheus.md b/specification/metrics/sdk_exporters/prometheus.md index c7c56ef37fa..511ccbeb90c 100644 --- a/specification/metrics/sdk_exporters/prometheus.md +++ b/specification/metrics/sdk_exporters/prometheus.md @@ -28,6 +28,6 @@ including the A Prometheus Exporter MAY offer configuration to add resource attributes as metric attributes. By default, it MUST NOT add any resource attributes as metric attributes. -The configuration SHOULD allow the user to select which resource attributes to copy (e.g. -include / exclude or regular expression based). Copied Resource attributes MUST NOT be +The configuration SHOULD allow the user to select which resource attributes to copy (e.g. +include / exclude or regular expression based). Copied Resource attributes MUST NOT be excluded from target_info, if target_info is enabled. From 3ac0f702edc023b75ffdeaef8488c76ff519ea06 Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Wed, 22 Nov 2023 21:55:51 +0200 Subject: [PATCH 13/15] Update specification/compatibility/prometheus_and_openmetrics.md Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com> --- 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 bfe163ede49..caa4c70c98e 100644 --- a/specification/compatibility/prometheus_and_openmetrics.md +++ b/specification/compatibility/prometheus_and_openmetrics.md @@ -385,7 +385,7 @@ OpenMetrics exemplar unless they would exceed the OpenMetrics In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to a single [`target_info` metric](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems) -if the resource is not [empty](../resource/sdk.md#the-empty-resource); +if the resource is not [empty](../resource/sdk.md#the-empty-resource). The resource attributes MAY be copied to labels of exported metric families, if required by the exporter configuration, or MUST be dropped. The target_info metric MUST be an info-typed metric whose labels MUST include the resource attributes, and MUST NOT include From 1dd96ba5eb0943242f3df1309fbb0a034953e977 Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Wed, 22 Nov 2023 21:56:11 +0200 Subject: [PATCH 14/15] Update specification/compatibility/prometheus_and_openmetrics.md Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com> --- 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 caa4c70c98e..7f36beddf3c 100644 --- a/specification/compatibility/prometheus_and_openmetrics.md +++ b/specification/compatibility/prometheus_and_openmetrics.md @@ -386,7 +386,7 @@ OpenMetrics exemplar unless they would exceed the OpenMetrics In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to a single [`target_info` metric](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems) if the resource is not [empty](../resource/sdk.md#the-empty-resource). -The resource attributes MAY be copied to labels of exported metric families, +The resource attributes MAY be copied to labels of exported metric families if required by the exporter configuration, or MUST be dropped. The target_info metric MUST be an info-typed metric whose labels MUST include the resource attributes, and MUST NOT include any other labels. There MUST be at most one target_info metric exposed on an SDK From 55557d205bd4b25fcee8fc9b8311a62efa18f43a Mon Sep 17 00:00:00 2001 From: Asaf Mesika Date: Wed, 22 Nov 2023 21:56:55 +0200 Subject: [PATCH 15/15] Update specification/metrics/sdk_exporters/prometheus.md Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com> --- specification/metrics/sdk_exporters/prometheus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/metrics/sdk_exporters/prometheus.md b/specification/metrics/sdk_exporters/prometheus.md index 511ccbeb90c..f72062e7c7a 100644 --- a/specification/metrics/sdk_exporters/prometheus.md +++ b/specification/metrics/sdk_exporters/prometheus.md @@ -30,4 +30,4 @@ A Prometheus Exporter MAY offer configuration to add resource attributes as metr By default, it MUST NOT add any resource attributes as metric attributes. The configuration SHOULD allow the user to select which resource attributes to copy (e.g. include / exclude or regular expression based). Copied Resource attributes MUST NOT be -excluded from target_info, if target_info is enabled. +excluded from target_info.