Sentry error handling if DSN fail

This commit is contained in:
Zeecka
2025-12-31 16:26:10 +01:00
parent 5c5e63dbea
commit 531bdc9d81
+20 -15
View File
@@ -25,18 +25,23 @@ def initialize_sentry() -> None:
if not SENTRY_DSN or sentry_sdk.Hub.current.client is not None: if not SENTRY_DSN or sentry_sdk.Hub.current.client is not None:
return return
sentry_sdk.init( try:
dsn=SENTRY_DSN, sentry_sdk.init(
integrations=[ dsn=SENTRY_DSN,
FlaskIntegration(), integrations=[
SqlalchemyIntegration(), FlaskIntegration(),
RqIntegration(), SqlalchemyIntegration(),
ThreadingIntegration(propagate_hub=True), RqIntegration(),
], ThreadingIntegration(propagate_hub=True),
traces_sample_rate=SENTRY_TRACES_SAMPLE_RATE, ],
profiles_sample_rate=SENTRY_PROFILES_SAMPLE_RATE, traces_sample_rate=SENTRY_TRACES_SAMPLE_RATE,
environment=SENTRY_ENVIRONMENT, profiles_sample_rate=SENTRY_PROFILES_SAMPLE_RATE,
release=SENTRY_RELEASE, environment=SENTRY_ENVIRONMENT,
send_default_pii=False, release=SENTRY_RELEASE,
enable_tracing=True, send_default_pii=False,
) enable_tracing=True,
)
except sentry_sdk.utils.BadDsn as e:
print(f"Sentry DSN is invalid, skipping Sentry initialization: {e}")
except Exception as e:
print(f"Sentry initialization failed: {e}")