Skip to content

Commit c8b3ccc

Browse files
estebanx64tiangolo
andauthored
🥅 Set up Sentry for FastAPI applications (#1136)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
1 parent 31f6042 commit c8b3ccc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

backend/app/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sentry_sdk
12
from fastapi import FastAPI
23
from fastapi.routing import APIRoute
34
from starlette.middleware.cors import CORSMiddleware
@@ -10,6 +11,9 @@ def custom_generate_unique_id(route: APIRoute) -> str:
1011
return f"{route.tags[0]}-{route.name}"
1112

1213

14+
if settings.SENTRY_DSN:
15+
sentry_sdk.init(dsn=str(settings.SENTRY_DSN), enable_tracing=True)
16+
1317
app = FastAPI(
1418
title=settings.PROJECT_NAME,
1519
openapi_url=f"{settings.API_V1_STR}/openapi.json",

0 commit comments

Comments
 (0)