🔨 Add OTel/Jeager to start HTTP/SQL requests monitoring

This commit is contained in:
2023-05-02 23:02:09 +02:00
parent 07d43bfcb4
commit 6aa28f7bfb
4 changed files with 98 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
from sqlalchemy import text
from sqlalchemy.ext.asyncio import (
async_sessionmaker,
@@ -26,6 +27,8 @@ class Database:
# TODO: Preserve UserLastStopSearchResults table from drop.
self._engine = create_async_engine(db_path)
if self._engine is not None:
SQLAlchemyInstrumentor().instrument(engine=self._engine.sync_engine)
self._session_maker = async_sessionmaker(
self._engine, expire_on_commit=False, class_=AsyncSession
)