From 15449d105acf8e5d02c3a8aeb4f94cd85ce0e141 Mon Sep 17 00:00:00 2001 From: Lev Vereshchagin Date: Mon, 29 Sep 2025 17:25:37 +0300 Subject: [PATCH] Use global Prometheus registry instead of custom collector registry in FastStream bootstrapper --- microbootstrap/bootstrappers/faststream.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/microbootstrap/bootstrappers/faststream.py b/microbootstrap/bootstrappers/faststream.py index 01b45a8..37cc01e 100644 --- a/microbootstrap/bootstrappers/faststream.py +++ b/microbootstrap/bootstrappers/faststream.py @@ -76,12 +76,11 @@ def is_ready(self) -> bool: return bool(self.instrument_config.prometheus_middleware_cls and super().is_ready()) def bootstrap_before(self) -> dict[str, typing.Any]: - self.collector_registry = prometheus_client.CollectorRegistry() return { "asgi_routes": ( ( self.instrument_config.prometheus_metrics_path, - prometheus_client.make_asgi_app(self.collector_registry), + prometheus_client.make_asgi_app(prometheus_client.REGISTRY), ), ) } @@ -89,7 +88,7 @@ def bootstrap_before(self) -> dict[str, typing.Any]: def bootstrap_after(self, application: AsgiFastStream) -> AsgiFastStream: # type: ignore[override] if self.instrument_config.prometheus_middleware_cls and application.broker: application.broker.add_middleware( - self.instrument_config.prometheus_middleware_cls(registry=self.collector_registry) + self.instrument_config.prometheus_middleware_cls(registry=prometheus_client.REGISTRY) ) return application