Tweak for tracing setup (#9865)

- DB_ENGINE is of the form "django.db.backends.postgresql", not "postgesql"
This commit is contained in:
Oliver 2025-06-26 09:29:03 +10:00 committed by GitHub
parent 2738d286de
commit 1b0de3610f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -163,10 +163,12 @@ def setup_instruments(db_engine: str): # pragma: no cover
RequestsInstrumentor().instrument()
SystemMetricsInstrumentor().instrument()
db_engine = str(db_engine).lower().strip()
# DBs
if db_engine == 'sqlite':
if 'sqlite' in db_engine:
SQLite3Instrumentor().instrument()
elif db_engine == 'postgresql':
elif 'postgresql' in db_engine:
try:
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
@ -175,7 +177,7 @@ def setup_instruments(db_engine: str): # pragma: no cover
)
except ModuleNotFoundError:
pass
elif db_engine == 'mysql':
elif 'mysql' in db_engine:
try:
from opentelemetry.instrumentation.pymysql import PyMySQLInstrumentor