Skip to content
Snippets Groups Projects
Unverified Commit 1092718c authored by Erik Johnston's avatar Erik Johnston Committed by GitHub
Browse files

Fix logging context when opening new DB connection (#10141)

Fixes #10140
parent 9e4610cc
No related branches found
No related tags found
No related merge requests found
Report OpenTracing spans for database activity.
...@@ -91,12 +91,18 @@ def make_pool( ...@@ -91,12 +91,18 @@ def make_pool(
db_args = dict(db_config.config.get("args", {})) db_args = dict(db_config.config.get("args", {}))
db_args.setdefault("cp_reconnect", True) db_args.setdefault("cp_reconnect", True)
def _on_new_connection(conn):
# Ensure we have a logging context so we can correctly track queries,
# etc.
with LoggingContext("db.on_new_connection"):
engine.on_new_connection(
LoggingDatabaseConnection(conn, engine, "on_new_connection")
)
return adbapi.ConnectionPool( return adbapi.ConnectionPool(
db_config.config["name"], db_config.config["name"],
cp_reactor=reactor, cp_reactor=reactor,
cp_openfun=lambda conn: engine.on_new_connection( cp_openfun=_on_new_connection,
LoggingDatabaseConnection(conn, engine, "on_new_connection")
),
**db_args, **db_args,
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment