summary refs log tree commit diff
path: root/synapse/util/metrics.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-04-21 16:16:10 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2021-04-21 16:16:10 +0100
commitc7cd7b45456237ac9a493d5a43c50845ac3792e0 (patch)
tree63b02c3a5573c2206248dd49d124eabee56dbeaa /synapse/util/metrics.py
parentMerge commit '2fe0fb21f' into anoa/dinsic_release_1_31_0 (diff)
parentMerge tag 'v1.25.0rc1' into develop (diff)
downloadsynapse-c7cd7b45456237ac9a493d5a43c50845ac3792e0.tar.xz
Merge commit '0312266ee' into anoa/dinsic_release_1_31_0
Diffstat (limited to '')
-rw-r--r--synapse/util/metrics.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/util/metrics.py b/synapse/util/metrics.py

index ffdea0de8d..24123d5cc4 100644 --- a/synapse/util/metrics.py +++ b/synapse/util/metrics.py
@@ -108,7 +108,15 @@ class Measure: def __init__(self, clock, name): self.clock = clock self.name = name - parent_context = current_context() + curr_context = current_context() + if not curr_context: + logger.warning( + "Starting metrics collection from sentinel context: metrics will be lost" + ) + parent_context = None + else: + assert isinstance(curr_context, LoggingContext) + parent_context = curr_context self._logging_context = LoggingContext( "Measure[%s]" % (self.name,), parent_context )