Fix dictionary changed size during iteration in prometheus (#115005)

Fixes #104803
This commit is contained in:
J. Nick Koston 2024-04-05 23:50:29 -10:00 committed by Franck Nijhof
parent b29eb317bd
commit 90bc21b7f6
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -258,7 +258,7 @@ class PrometheusMetrics:
self, entity_id: str, friendly_name: str | None = None
) -> None:
"""Remove labelsets matching the given entity id from all metrics."""
for metric in self._metrics.values():
for metric in list(self._metrics.values()):
for sample in cast(list[prometheus_client.Metric], metric.collect())[
0
].samples: