Add notify business metrics
This commit is contained in:
@@ -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')
|
||||
Reference in New Issue
Block a user