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 GitHub
parent e85b9faa00
commit 7d5b39b9de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -257,7 +257,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: