Browse Source

Add debug logging when we enter/exit Measure block (#10183)

It can be helpful to know when trying to track down slow requests.
Erik Johnston 2 years ago
parent
commit
36c426e294
2 changed files with 6 additions and 0 deletions
  1. 1 0
      changelog.d/10183.misc
  2. 5 0
      synapse/util/metrics.py

+ 1 - 0
changelog.d/10183.misc

@@ -0,0 +1 @@
+Add debug logging for when we enter and exit `Measure` blocks.

+ 5 - 0
synapse/util/metrics.py

@@ -133,12 +133,17 @@ class Measure:
         self.start = self.clock.time()
         self._logging_context.__enter__()
         in_flight.register((self.name,), self._update_in_flight)
+
+        logger.debug("Entering block %s", self.name)
+
         return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         if self.start is None:
             raise RuntimeError("Measure() block exited without being entered")
 
+        logger.debug("Exiting block %s", self.name)
+
         duration = self.clock.time() - self.start
         usage = self.get_resource_usage()