From 5e7ced904c9cefd7f8dc3f55ff47e835855d1ff8 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Thu, 28 Sep 2023 20:58:41 +0100 Subject: [PATCH] chore: use prom to measure celery queue depth --- posthog/celery.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/posthog/celery.py b/posthog/celery.py index 7f41920f1aebc..7df6349c320de 100644 --- a/posthog/celery.py +++ b/posthog/celery.py @@ -57,6 +57,11 @@ labelnames=["task_name"], ) +CELERY_TASK_QUEUE_DEPTH_GAUGE = Gauge( + "posthog_celery_queue_depth", + "We use this to monitor the depth of the celery queue.", +) + # Using a string here means the worker doesn't have to serialize # the configuration object to child processes. # - namespace='CELERY' means all celery-related configuration keys @@ -684,6 +689,9 @@ def redis_celery_queue_depth(): try: llen = get_client().llen("celery") + CELERY_TASK_QUEUE_DEPTH_GAUGE.set(llen) + + # TODO this can be removed once we're using the prom metric for alerting with pushed_metrics_registry("celery_redis_queue_depth") as registry: depth_gauge = Gauge( "posthog_celery_queue_depth",