refactored
Some checks failed
Deploy on push / deploy (push) Failing after 6s

This commit is contained in:
2025-08-17 17:56:31 +03:00
parent e78e12eeee
commit 9a2b792f08
98 changed files with 702 additions and 904 deletions

30
utils/sentry.py Normal file
View File

@@ -0,0 +1,30 @@
import logging
import sentry_sdk
from sentry_sdk.integrations.ariadne import AriadneIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
from sentry_sdk.integrations.starlette import StarletteIntegration
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() -> None:
try:
logger.info("[utils.sentry] Sentry init started...")
sentry_sdk.init(
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("[utils.sentry] Sentry initialized successfully.")
except (sentry_sdk.utils.BadDsn, ImportError, ValueError, TypeError) as _e:
logger.warning("[utils.sentry] Failed to initialize Sentry", exc_info=True)