From 7ea630b776947ab82438d0ffa263b0f9d33ebff3 Mon Sep 17 00:00:00 2001 From: Ignas Kiela Date: Wed, 8 Dec 2021 10:22:32 +0200 Subject: [PATCH] Add webhook queue monitoring --- gitsrht/app.py | 3 +++ gitsrht/webhooks.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gitsrht/app.py b/gitsrht/app.py index 4928851..e9ccb56 100644 --- a/gitsrht/app.py +++ b/gitsrht/app.py @@ -48,6 +48,9 @@ class GitApp(ScmSrhtFlask): self.add_template_filter(url_quote) self.add_template_filter(commit_links) + from gitsrht.webhooks import webhook_metrics_collector + self.metrics_registry.register(webhook_metrics_collector) + @self.context_processor def inject(): notice = session.get("notice") diff --git a/gitsrht/webhooks.py b/gitsrht/webhooks.py index 6240d50..8a203fe 100644 --- a/gitsrht/webhooks.py +++ b/gitsrht/webhooks.py @@ -7,10 +7,13 @@ if not hasattr(db, "session"): db.init() from srht.webhook import Event from srht.webhook.celery import CeleryWebhook, make_worker +from srht.metrics import RedisQueueCollector from scmsrht.webhooks import UserWebhook import sqlalchemy as sa -worker = make_worker(broker=cfg("git.sr.ht", "webhooks")) +webhook_broker = cfg("git.sr.ht", "webhooks") +worker = make_worker(broker=webhook_broker) +webhook_metrics_collector = RedisQueueCollector(webhook_broker, "srht_webhooks", "Webhook queue length") class RepoWebhook(CeleryWebhook): events = [ -- 2.38.4