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 authored and GitHub committed 2021-04-28 07:44:52 -04:00
1 parent fa6679e794
commit 10a08ab88a
2 files changed
+4 -1

No files matched your search

+1
View File
@@ -0,0 +1 @@
Fix a bug introduced in v1.32.0 where the associated connection was improperly logged for SQL logging statements.
+3 -1
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)