feat(metrics): add copykar_redis_queue_size gauge and update grafana queue panels

This commit is contained in:
mamad
2026-08-27 21:18:28 +03:30
parent 1510af647c
commit 4f5570850e
3 changed files with 74 additions and 18 deletions
+3 -1
View File
@@ -4,7 +4,7 @@ import logging
from typing import Optional
from core.queue import RedisQueue
from services.ai_processor import AIProcessor
from core.metrics import QUEUE_POSTS_GAUGE
from core.metrics import QUEUE_POSTS_GAUGE, REDIS_QUEUE_SIZE_GAUGE
logger = logging.getLogger(__name__)
@@ -29,6 +29,7 @@ class QueueConsumerService:
try:
qsize = await self.queue.qsize()
QUEUE_POSTS_GAUGE.labels(status="redis_incoming").set(qsize)
REDIS_QUEUE_SIZE_GAUGE.set(qsize)
if qsize > 0:
post_id = await self.queue.pop()
@@ -37,6 +38,7 @@ class QueueConsumerService:
await self.ai_processor.process_post(post_id)
new_qsize = await self.queue.qsize()
QUEUE_POSTS_GAUGE.labels(status="redis_incoming").set(new_qsize)
REDIS_QUEUE_SIZE_GAUGE.set(new_qsize)
except Exception as e:
logger.error(f"Error in queue consumer loop: {e}", exc_info=True)