Реализовать уровень 4: сквозные трассы, SLO, отказы и отчёт

This commit is contained in:
2026-11-21 12:18:33 +03:00
parent d0a062e2d2
commit 12181fa893
69 changed files with 52258 additions and 47 deletions
+4 -1
View File
@@ -15,6 +15,7 @@ from app.pipeline import (RETENTION_SECONDS, arm_from_env, broker_channel,
crash_if_armed, envelope, publish, retry_or_fail)
from app.storage import storage
from app.telemetry import configure, emit, install_termination_handler, shutdown
from app import advanced
logger = logging.getLogger("messenger.jobs")
@@ -87,7 +88,6 @@ async def relay_one(channel) -> bool:
{"id": row["id"]})
await db.commit()
logger.info("published job=%s attempt=%s", row["job_id"], row["attempt"])
emit("job.published", job_id=str(row["job_id"]), attempt=row["attempt"])
return True
@@ -98,6 +98,7 @@ async def main() -> None:
for name in ("aio_pika", "aiormq"):
logging.getLogger(name).setLevel(logging.CRITICAL)
await storage.start()
backlog = asyncio.create_task(advanced.backlog_loop(SessionLocal))
connection = None
try:
await arm_from_env("PUBLISHER_FAULT")
@@ -128,6 +129,8 @@ async def main() -> None:
connection = None
await asyncio.sleep(1)
finally:
backlog.cancel()
await asyncio.gather(backlog, return_exceptions=True)
if connection:
await connection.close()
await storage.close()