Add notify business metrics

This commit is contained in:
Codex
2026-07-01 18:47:26 +03:00
parent a7147b951e
commit 910fc8d37f
4 changed files with 117 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ from datetime import datetime
from typing import Literal, Optional
from pydantic import BaseModel, EmailStr, Field
from src.infrastructure.rabbit.broker import email_code_queue
from src.infrastructure.metrics import observe_notify
code_broker = RabbitRouter(settings.RABBIT_URL)
@@ -76,10 +77,16 @@ async def consume_email_code(
year=datetime.now().year,
)
await sender.send(
to=msg_body.payload.email,
subject='Экса — код подтверждения',
body=html,
plain=text,
inline_png=(EXA_LOGO_CID, logo_png) if logo_png else None,
)
observe_notify('email', msg_body.event, 'received')
try:
await sender.send(
to=msg_body.payload.email,
subject='Экса — код подтверждения',
body=html,
plain=text,
inline_png=(EXA_LOGO_CID, logo_png) if logo_png else None,
)
except Exception:
observe_notify('email', msg_body.event, 'error')
raise
observe_notify('email', msg_body.event, 'sent')