blob: dea6bec2708d5ff26532af1e8606f98f879a2950 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import logging
from jb.settings import get_settings
settings = get_settings()
if settings.debug:
LOG_LEVEL = logging.DEBUG
else:
LOG_LEVEL = logging.WARNING
if settings.sentry:
import sentry_sdk
from sentry_sdk.integrations.fastapi import FastApiIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.redis import RedisIntegration
# --- Sentry Configuration ---
sentry_logging = LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=logging.ERROR, # Send errors as events
)
sentry_sdk.init(
dsn=str(settings.sentry),
integrations=[FastApiIntegration(), sentry_logging, RedisIntegration()],
send_default_pii=True,
sample_rate=1,
traces_sample_rate=0.1,
)
|