Skip to content

Commit 442621d

Browse files
authored
Fixed prometheus multiprocessing registry (#620)
1 parent 3f1d0d1 commit 442621d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

taskiq/middlewares/prometheus_middleware.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,22 @@ 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 ( # noqa: PLC0415
88+
CollectorRegistry,
89+
start_http_server,
90+
)
8891
from prometheus_client.multiprocess import ( # noqa: PLC0415
8992
MultiProcessCollector,
9093
)
9194

9295
if self.broker.is_worker_process:
9396
try:
94-
MultiProcessCollector(REGISTRY)
97+
registry = CollectorRegistry()
98+
MultiProcessCollector(registry)
9599
start_http_server(
96100
port=self.server_port,
97101
addr=self.server_addr,
102+
registry=registry,
98103
)
99104
except OSError as exc:
100105
logger.debug("Cannot start prometheus server: %s", exc)

0 commit comments

Comments
 (0)