diff --git a/services/db.py b/services/db.py index 7d37e45a..58c4588d 100644 --- a/services/db.py +++ b/services/db.py @@ -17,7 +17,13 @@ from settings import DB_URL # Подключение к базе данных SQLAlchemy -engine = create_engine(DB_URL, echo=False, pool_size=10, max_overflow=20) +engine = create_engine(DB_URL, + echo=False, + pool_size=10, + max_overflow=20, + pool_timeout=30, # Время ожидания свободного соединения + pool_recycle=1800, # Время жизни соединения +) inspector = inspect(engine) configure_mappers() T = TypeVar("T") @@ -88,7 +94,7 @@ warnings.simplefilter("always", exc.SAWarning) @event.listens_for(Engine, "before_cursor_execute") def before_cursor_execute(conn, cursor, statement, parameters, context, executemany): conn.query_start_time = time.time() - conn.last_statement = "" + conn.last_statement = None @event.listens_for(Engine, "after_cursor_execute") diff --git a/services/sentry.py b/services/sentry.py index 48fdd8e3..b9880c44 100644 --- a/services/sentry.py +++ b/services/sentry.py @@ -1,16 +1,9 @@ import sentry_sdk -import logging from sentry_sdk.integrations.ariadne import AriadneIntegration from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from sentry_sdk.integrations.starlette import StarletteIntegration -from sentry_sdk.integrations.logging import LoggingIntegration from settings import GLITCHTIP_DSN -sentry_logging = LoggingIntegration( - level=logging.DEBUG, # Capture info and above as breadcrumbs - event_level=logging.ERROR # Send errors as events -) - def start_sentry(): # sentry monitoring @@ -28,8 +21,7 @@ def start_sentry(): integrations=[ StarletteIntegration(), AriadneIntegration(), - SqlalchemyIntegration(), - sentry_logging + SqlalchemyIntegration() ], ) except Exception as e: