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

It can be helpful to know when trying to track down slow requests.
This commit is contained in:
Erik Johnston 2021-06-16 13:29:54 +01:00 committed by GitHub
parent 2c240213f4
commit 36c426e294
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

1
changelog.d/10183.misc Normal file
View file

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

View file

@ -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()