From 44dde01d03e4ae118df07476caac0cb0668b87b3 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Fri, 29 Sep 2023 08:43:50 +0100 Subject: [PATCH] chore: use prom to measure celery queue depth (#17682) --- 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",