Skip to content

Commit d1c331c

Browse files
authored
Prometheus Exporter sanitize info metric
1 parent 3dfe224 commit d1c331c

File tree

1 file changed

+2
-0
lines changed
  • exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus

1 file changed

+2
-0
lines changed

exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ def _create_info_metric(
378378
self, name: str, description: str, attributes: Dict[str, str]
379379
) -> InfoMetricFamily:
380380
"""Create an Info Metric Family with list of attributes"""
381+
# sanitize the attribute names according to Prometheus rule
382+
attributes = {self._sanitize(key): value for key, value in attributes.items()}
381383
info = InfoMetricFamily(name, description, labels=attributes)
382384
info.add_metric(labels=list(attributes.keys()), value=attributes)
383385
return info

0 commit comments

Comments
 (0)