From d1c331c4cd45f5eb0a2fe1e47f4b0dba765e0d22 Mon Sep 17 00:00:00 2001 From: Clemens Korner Date: Thu, 7 Dec 2023 09:58:09 +0100 Subject: [PATCH] Prometheus Exporter sanitize info metric --- .../src/opentelemetry/exporter/prometheus/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py b/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py index 8d9e18d733..c0b8729546 100644 --- a/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py +++ b/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py @@ -378,6 +378,8 @@ def _create_info_metric( self, name: str, description: str, attributes: Dict[str, str] ) -> InfoMetricFamily: """Create an Info Metric Family with list of attributes""" + # sanitize the attribute names according to Prometheus rule + attributes = {self._sanitize(key): value for key, value in attributes.items()} info = InfoMetricFamily(name, description, labels=attributes) info.add_metric(labels=list(attributes.keys()), value=attributes) return info