mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-07 11:11:51 +00:00
Fix logging context when opening new DB connection (#10141)
Fixes #10140
This commit is contained in:
parent
9e4610cc27
commit
1092718cac
1
changelog.d/10141.feature
Normal file
1
changelog.d/10141.feature
Normal file
@ -0,0 +1 @@
|
||||
Report OpenTracing spans for database activity.
|
@ -91,12 +91,18 @@ def make_pool(
|
||||
db_args = dict(db_config.config.get("args", {}))
|
||||
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(
|
||||
db_config.config["name"],
|
||||
cp_reactor=reactor,
|
||||
cp_openfun=lambda conn: engine.on_new_connection(
|
||||
LoggingDatabaseConnection(conn, engine, "on_new_connection")
|
||||
),
|
||||
cp_openfun=_on_new_connection,
|
||||
**db_args,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user