-
-
Notifications
You must be signed in to change notification settings - Fork 348
Description
dramatiq version: 1.17.1
The dramatiq.middleware.prometheus.Prometheus class defines after_process_boot(self, broker), but the Dramatiq broker calls emit_after("worker_boot", ...), which looks for after_worker_boot(...) instead. As a result, after_process_boot() is never invoked and key attributes like .message_durations, .inprogress_messages, etc., are never initialized.
The Prometheus middleware should hook properly into the worker_boot lifecycle and initialize its internal metrics.
Add this method to Prometheus middleware (in dramatiq.middleware.prometheus):
def after_worker_boot(self, broker, worker):
self.after_process_boot(broker)
Work-around ================================================
Derive a class:
class PatchedPrometheus(Prometheus):
def after_worker_boot(self, broker, worker):
self.after_process_boot(broker)
In your worker =================================================
Remove any existing Prometheus middleware
dramatiq.get_broker().middleware = [
mw for mw in dramatiq.get_broker().middleware
if not isinstance(mw, Prometheus)
]
dramatiq.get_broker().add_middleware(PatchedPrometheus())