feat: ЛР6 - наблюдаемость OpenTelemetry, Grafana и исследование цены наблюдаемости

This commit is contained in:
Ильяс
2026-11-27 20:09:36 +03:00
parent 38a00e1930
commit c549409d7b
25 changed files with 2599 additions and 187 deletions
+12 -1
View File
@@ -8,6 +8,7 @@ from typing import Any
import asyncpg
from app.broker import publisher
from app.telemetry import set_oldest_job_age, set_queue_depth
logger = logging.getLogger("messenger.outbox")
@@ -90,7 +91,17 @@ class OutboxRelay:
while self._running:
try:
dispatched = await self.process_pending(pool)
# Если были отправлены задачи, проверяем сразу следующую порцию
count = await publisher.get_queue_message_count()
set_queue_depth(count)
async with pool.acquire() as conn:
age = await conn.fetchval(
"""
SELECT COALESCE(EXTRACT(EPOCH FROM (NOW() - MIN(created_at))), 0.0)
FROM outbox_jobs
WHERE status = 'pending'
"""
)
set_oldest_job_age(float(age or 0.0))
if dispatched > 0:
continue
except asyncio.CancelledError: