summary refs log tree commit diff
path: root/synapse/metrics/background_process_metrics.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-12-31 11:43:55 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-12-31 11:43:55 +0000
commit8f05de1d97fc67786e9e1d2ba1a79ffb4dafb865 (patch)
tree11be269c222a7a1ae73efd131d48151cb174ac1b /synapse/metrics/background_process_metrics.py
parentMerge commit '97647b33c' into dinsic (diff)
parentAdd type hints to profile and base handlers. (#8609) (diff)
downloadsynapse-8f05de1d97fc67786e9e1d2ba1a79ffb4dafb865.tar.xz
Merge commit 'de5cafe98' into dinsic
Diffstat (limited to 'synapse/metrics/background_process_metrics.py')
-rw-r--r--synapse/metrics/background_process_metrics.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/synapse/metrics/background_process_metrics.py b/synapse/metrics/background_process_metrics.py

index 5b73463504..ea5f1c7b62 100644 --- a/synapse/metrics/background_process_metrics.py +++ b/synapse/metrics/background_process_metrics.py
@@ -24,6 +24,7 @@ from prometheus_client.core import REGISTRY, Counter, Gauge from twisted.internet import defer from synapse.logging.context import LoggingContext, PreserveLoggingContext +from synapse.logging.opentracing import start_active_span if TYPE_CHECKING: import resource @@ -197,14 +198,14 @@ def run_as_background_process(desc: str, func, *args, **kwargs): with BackgroundProcessLoggingContext(desc) as context: context.request = "%s-%i" % (desc, count) - try: - result = func(*args, **kwargs) + with start_active_span(desc, tags={"request_id": context.request}): + result = func(*args, **kwargs) - if inspect.isawaitable(result): - result = await result + if inspect.isawaitable(result): + result = await result - return result + return result except Exception: logger.exception( "Background process '%s' threw an exception", desc,