summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-02-09 10:16:50 +0000
committerErik Johnston <erik@matrix.org>2016-02-09 10:28:13 +0000
commit241b71852e549de8a3042f8a7c22ba56af482657 (patch)
tree16223fb5f7f33cb23837865d7b5d59a1c8e86ec1
parentCreate new context when measuring (diff)
downloadsynapse-241b71852e549de8a3042f8a7c22ba56af482657.tar.xz
Fix bug in util.metrics.Measure
-rw-r--r--synapse/util/metrics.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/synapse/util/metrics.py b/synapse/util/metrics.py
index f70d855122..7c6899aa1c 100644
--- a/synapse/util/metrics.py
+++ b/synapse/util/metrics.py
@@ -63,6 +63,8 @@ class Measure(object):
         self.new_context.__enter__()
 
     def __exit__(self, exc_type, exc_val, exc_tb):
+        current_context = LoggingContext.current_context()
+
         self.new_context.__exit__(exc_type, exc_val, exc_tb)
         if exc_type is not None:
             return
@@ -72,7 +74,7 @@ class Measure(object):
 
         context = self.new_context
 
-        if context != self.start_context:
+        if context != current_context:
             logger.warn(
                 "Context have unexpectedly changed from '%s' to '%s'. (%r)",
                 context, self.start_context, self.name