diff options
author | Richard van der Hoff <richard@matrix.org> | 2019-10-18 10:11:40 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2019-10-18 10:11:40 +0100 |
commit | 80003dfcd503a72cb4da515b17c3765faccc2ce6 (patch) | |
tree | 448fc279a9278566283721bb6a0c86f17efdbd36 /synapse/logging/opentracing.py | |
parent | changelog (diff) | |
parent | Remove dead changelog file (diff) | |
download | synapse-80003dfcd503a72cb4da515b17c3765faccc2ce6.tar.xz |
Merge remote-tracking branch 'origin/develop' into rav/event_auth/1
Diffstat (limited to 'synapse/logging/opentracing.py')
-rw-r--r-- | synapse/logging/opentracing.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/synapse/logging/opentracing.py b/synapse/logging/opentracing.py index cd1ff6a518..0638cec429 100644 --- a/synapse/logging/opentracing.py +++ b/synapse/logging/opentracing.py @@ -169,6 +169,7 @@ import contextlib import inspect import logging import re +import types from functools import wraps from typing import Dict @@ -778,8 +779,7 @@ def trace_servlet(servlet_name, extract_context=False): return func @wraps(func) - @defer.inlineCallbacks - def _trace_servlet_inner(request, *args, **kwargs): + async def _trace_servlet_inner(request, *args, **kwargs): request_tags = { "request_id": request.get_request_id(), tags.SPAN_KIND: tags.SPAN_KIND_RPC_SERVER, @@ -796,8 +796,14 @@ def trace_servlet(servlet_name, extract_context=False): scope = start_active_span(servlet_name, tags=request_tags) with scope: - result = yield defer.maybeDeferred(func, request, *args, **kwargs) - return result + result = func(request, *args, **kwargs) + + if not isinstance(result, (types.CoroutineType, defer.Deferred)): + # Some servlets aren't async and just return results + # directly, so we handle that here. + return result + + return await result return _trace_servlet_inner |