summary refs log tree commit diff
path: root/synapse/logging/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/logging/context.py')
-rw-r--r--synapse/logging/context.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/logging/context.py b/synapse/logging/context.py
index 4b8d6037af..e52567afa0 100644
--- a/synapse/logging/context.py
+++ b/synapse/logging/context.py
@@ -821,13 +821,15 @@ def run_in_background(
     d: "defer.Deferred[R]"
     if isinstance(res, typing.Coroutine):
         # Wrap the coroutine in a `Deferred`.
-        d = defer.ensureDeferred(res)
+        d = defer.ensureDeferred(measure_coroutine(current.name, res))
     elif isinstance(res, defer.Deferred):
         d = res
     elif isinstance(res, Awaitable):
         # `res` is probably some kind of completed awaitable, such as a `DoneAwaitable`
         # or `Future` from `make_awaitable`.
-        d = defer.ensureDeferred(_unwrap_awaitable(res))
+        d = defer.ensureDeferred(
+            measure_coroutine(current.name, _unwrap_awaitable(res))
+        )
     else:
         # `res` is a plain value. Wrap it in a `Deferred`.
         d = defer.succeed(res)