Skip to content

Commit 315576b

Browse files
committed
feat(backend): reduce RQ worker registry sweep verbosity and frequency
Generated-By: PostHog Code
1 parent 275d3a8 commit 315576b

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

backend/handler/rq_worker.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import logging
2+
from typing import Any
3+
4+
from rq import Worker
5+
6+
7+
class _DropRegistryCleanupFilter(logging.Filter):
8+
"""Drops RQ's periodic "cleaning registries for queue" INFO line.
9+
10+
The maintenance sweep still runs (crash recovery for orphaned jobs, TTL
11+
reaping, stale worker pruning); only its log record is suppressed so it
12+
does not flood logs on every maintenance interval.
13+
"""
14+
15+
def filter(self, record: logging.LogRecord) -> bool:
16+
return "cleaning registries for queue" not in record.getMessage()
17+
18+
19+
class RomMWorker(Worker):
20+
"""RQ worker that silences the noisy registry-cleanup log line."""
21+
22+
def __init__(self, *args: Any, **kwargs: Any) -> None:
23+
super().__init__(*args, **kwargs)
24+
if not any(isinstance(f, _DropRegistryCleanupFilter) for f in self.log.filters):
25+
self.log.addFilter(_DropRegistryCleanupFilter())

docker/init_scripts/init

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,12 @@ start_bin_rq_worker() {
233233
fi
234234

235235
# Set PYTHONPATH so RQ can find the tasks module
236+
# Sweep registries hourly instead of every ~10 min, using a worker class that
237+
# drops the noisy per-sweep "cleaning registries for queue" log line.
236238
PYTHONPATH="/backend:${PYTHONPATH-}" rq worker \
237239
--path /backend \
240+
--worker-class handler.rq_worker.RomMWorker \
241+
--maintenance-interval 3600 \
238242
--pid /tmp/rq_worker.pid \
239243
--url "${redis_url}" \
240244
--results-ttl "${TASK_RESULT_TTL:-86400}" \

entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ else
6969
fi
7070

7171
# Set PYTHONPATH so RQ can find the tasks module
72+
# Sweep registries hourly instead of every ~10 min, using a worker class that
73+
# drops the noisy per-sweep "cleaning registries for queue" log line.
7274
PYTHONPATH="/app/backend:${PYTHONPATH-}" rq worker \
7375
--path /app/backend \
76+
--worker-class handler.rq_worker.RomMWorker \
77+
--maintenance-interval 3600 \
7478
--pid /tmp/rq_worker.pid \
7579
--url "${REDIS_URL}" \
7680
--logging_level "${LOGLEVEL:-INFO}" \

0 commit comments

Comments
 (0)