Skip to content

Commit 9c77959

Browse files
committed
Fixed prometheus multiprocessing registry
1 parent 3f1d0d1 commit 9c77959

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

taskiq/middlewares/prometheus_middleware.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,19 @@ def startup(self) -> None:
8484
This function starts prometheus server.
8585
It starts it only in case if it's a worker process.
8686
"""
87-
from prometheus_client import REGISTRY, start_http_server # noqa: PLC0415
87+
from prometheus_client import CollectorRegistry, start_http_server # noqa: PLC0415
8888
from prometheus_client.multiprocess import ( # noqa: PLC0415
8989
MultiProcessCollector,
9090
)
9191

9292
if self.broker.is_worker_process:
9393
try:
94-
MultiProcessCollector(REGISTRY)
94+
registry = CollectorRegistry()
95+
MultiProcessCollector(registry)
9596
start_http_server(
9697
port=self.server_port,
9798
addr=self.server_addr,
99+
registry=registry,
98100
)
99101
except OSError as exc:
100102
logger.debug("Cannot start prometheus server: %s", exc)

0 commit comments

Comments
 (0)