diff --git a/app/main.py b/app/main.py index 8897235..9f7087b 100644 --- a/app/main.py +++ b/app/main.py @@ -9,6 +9,7 @@ from app.utils import generate_email_map from app.email import send_email from dotenv import load_dotenv +from sentry_sdk.integrations.logging import LoggingIntegration @asynccontextmanager @@ -25,6 +26,23 @@ async def lifespan(app: FastAPI): app = FastAPI(lifespan=lifespan) +# Setup sentry logging +sentry_logging = LoggingIntegration( + level=logging.INFO, # Capture info and above as breadcrumbs + event_level=logging.ERROR # Send errors as events +) +sentry_sdk.init( + dsn=os.environ["SENTRY_DSN"], + integrations=[ + sentry_logging, + ], + + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + # We recommend adjusting this value in production, + traces_sample_rate=1.0, +) + class Email(BaseModel): email_address: str