This commit is contained in:
parent
6a6df10825
commit
e2b54b37dd
|
@ -2,25 +2,28 @@ import sentry_sdk
|
||||||
from sentry_sdk.integrations.ariadne import AriadneIntegration
|
from sentry_sdk.integrations.ariadne import AriadneIntegration
|
||||||
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
|
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
|
||||||
from sentry_sdk.integrations.starlette import StarletteIntegration
|
from sentry_sdk.integrations.starlette import StarletteIntegration
|
||||||
|
import logging
|
||||||
|
|
||||||
from settings import GLITCHTIP_DSN
|
from settings import GLITCHTIP_DSN
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
# Настройка логирования для отправки логов в Sentry
|
||||||
|
sentry_logging_handler = sentry_sdk.integrations.logging.SentryHandler(level=logging.WARNING)
|
||||||
|
logger.addHandler(sentry_logging_handler)
|
||||||
|
logger.setLevel(logging.DEBUG) # Более подробное логирование
|
||||||
|
|
||||||
def start_sentry():
|
def start_sentry():
|
||||||
# sentry monitoring
|
|
||||||
try:
|
try:
|
||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
GLITCHTIP_DSN,
|
dsn=GLITCHTIP_DSN,
|
||||||
# Set traces_sample_rate to 1.0 to capture 100%
|
traces_sample_rate=1.0, # Захват 100% транзакций
|
||||||
# of transactions for performance monitoring.
|
profiles_sample_rate=1.0, # Профилирование 100% транзакций
|
||||||
traces_sample_rate=1.0,
|
|
||||||
# Set profiles_sample_rate to 1.0 to profile 100%
|
|
||||||
# of sampled transactions.
|
|
||||||
# We recommend adjusting this value in production.
|
|
||||||
profiles_sample_rate=1.0,
|
|
||||||
enable_tracing=True,
|
enable_tracing=True,
|
||||||
integrations=[StarletteIntegration(), AriadneIntegration(), SqlalchemyIntegration()],
|
integrations=[StarletteIntegration(), AriadneIntegration(), SqlalchemyIntegration()],
|
||||||
|
send_default_pii=True, # Отправка информации о пользователе (PII)
|
||||||
)
|
)
|
||||||
|
logger.info("[services.sentry] Sentry initialized successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("[services.sentry] init error")
|
logger.error("[services.sentry] Failed to initialize Sentry", exc_info=True)
|
||||||
print(e)
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user