feat(metrics): add copykar_redis_queue_size gauge and update grafana queue panels
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user