diff --git a/services/sentry.py b/services/sentry.py index 04f4f377..2b42c1ed 100644 --- a/services/sentry.py +++ b/services/sentry.py @@ -2,25 +2,28 @@ import sentry_sdk from sentry_sdk.integrations.ariadne import AriadneIntegration from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from sentry_sdk.integrations.starlette import StarletteIntegration +import logging 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(): - # sentry monitoring try: sentry_sdk.init( - GLITCHTIP_DSN, - # Set traces_sample_rate to 1.0 to capture 100% - # of transactions for performance monitoring. - 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, + dsn=GLITCHTIP_DSN, + traces_sample_rate=1.0, # Захват 100% транзакций + profiles_sample_rate=1.0, # Профилирование 100% транзакций enable_tracing=True, integrations=[StarletteIntegration(), AriadneIntegration(), SqlalchemyIntegration()], + send_default_pii=True, # Отправка информации о пользователе (PII) ) + logger.info("[services.sentry] Sentry initialized successfully.") except Exception as e: - print("[services.sentry] init error") - print(e) + logger.error("[services.sentry] Failed to initialize Sentry", exc_info=True) + +