summary refs log tree commit diff
path: root/synapse/util/metrics.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-01-07 10:35:04 +0000
committerErik Johnston <erik@matrix.org>2021-01-07 10:35:04 +0000
commit91fd180be1198416edb08505dab33fb7eb02dae9 (patch)
tree1b598ca4f6d3347935ac46ce27fd4913f2764646 /synapse/util/metrics.py
parentMerge branch 'release-v1.25.0' of github.com:matrix-org/synapse into matrix-o... (diff)
parentEmpty iterables should count towards cache usage. (#9028) (diff)
downloadsynapse-91fd180be1198416edb08505dab33fb7eb02dae9.tar.xz
Merge remote-tracking branch 'origin/develop' into matrix-org-hotfixes
Diffstat (limited to 'synapse/util/metrics.py')
-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 )