INNER CODE UNIT · Python
_init_sentry
flukelaster/ai-trading-agent · backend/app/main.py:75
def _init_sentry() -> None:
"""Wire Sentry when ``SENTRY_DSN`` is set. Skipped silently otherwise.
Initialized at import time (before FastAPI app construction) so the SDK can
capture errors that happen during module import / lifespan setup, not only
request handlers.
"""
if not settings.sentry_dsn:
return
try:
import sentry_sdk
from sentry_sdk.integrations.fastapi import FastApiIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
sentry_sdk.init(
dsn=settings.sentry_dsn,
environment=settings.sentry_environment,
traces_sample_rate=settings.sentry_traces_sample_rate,