Use the parent's logging context name for runWithConnection. (#9895)

This fixes a regression where the logging context for runWithConnection
was reported as runWithConnection instead of the connection name,
e.g. "POST-XYZ".
This commit is contained in:
Patrick Cloke 2021-04-28 07:44:52 -04:00 committed by GitHub
parent fa6679e794
commit 10a08ab88a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

1
changelog.d/9895.bugfix Normal file
View File

@ -0,0 +1 @@
Fix a bug introduced in v1.32.0 where the associated connection was improperly logged for SQL logging statements.

View File

@ -715,7 +715,9 @@ class DatabasePool:
# pool).
assert not self.engine.in_transaction(conn)
with LoggingContext("runWithConnection", parent_context) as context:
with LoggingContext(
str(curr_context), parent_context=parent_context
) as context:
sched_duration_sec = monotonic_time() - start_time
sql_scheduling_timer.observe(sched_duration_sec)
context.add_database_scheduled(sched_duration_sec)