Skip to content

Commit 3d596ae

Browse files
authored
fix: remove sentry hard dependency (#494)
1 parent 0b7d3f0 commit 3d596ae

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

app/main.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,26 @@ def __init__(self):
5959

6060
def setup_sentry(self):
6161
if os.getenv("ENV") == "production":
62-
sentry_sdk.init(
63-
dsn=os.getenv("SENTRY_DSN"),
64-
traces_sample_rate=0.25,
65-
profiles_sample_rate=1.0,
66-
)
62+
try:
63+
# Explicitly configure integrations to avoid auto-enabling Strawberry
64+
# which causes crashes when Strawberry is not installed
65+
from sentry_sdk.integrations.fastapi import FastApiIntegration
66+
from sentry_sdk.integrations.logging import LoggingIntegration
67+
from sentry_sdk.integrations.stdlib import StdlibIntegration
68+
69+
sentry_sdk.init(
70+
dsn=os.getenv("SENTRY_DSN"),
71+
traces_sample_rate=0.25,
72+
profiles_sample_rate=1.0,
73+
default_integrations=False,
74+
integrations=[
75+
FastApiIntegration(),
76+
LoggingIntegration(),
77+
StdlibIntegration(),
78+
],
79+
)
80+
except Exception as e:
81+
logging.warning(f"Sentry initialization failed (non-fatal): {e}")
6782

6883
def setup_phoenix_tracing(self):
6984
try:

0 commit comments

Comments
 (0)