Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 36c426e

Browse files
authored
Add debug logging when we enter/exit Measure block (#10183)
It can be helpful to know when trying to track down slow requests.
1 parent 2c24021 commit 36c426e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

changelog.d/10183.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add debug logging for when we enter and exit `Measure` blocks.

synapse/util/metrics.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,17 @@ def __enter__(self) -> "Measure":
133133
self.start = self.clock.time()
134134
self._logging_context.__enter__()
135135
in_flight.register((self.name,), self._update_in_flight)
136+
137+
logger.debug("Entering block %s", self.name)
138+
136139
return self
137140

138141
def __exit__(self, exc_type, exc_val, exc_tb):
139142
if self.start is None:
140143
raise RuntimeError("Measure() block exited without being entered")
141144

145+
logger.debug("Exiting block %s", self.name)
146+
142147
duration = self.clock.time() - self.start
143148
usage = self.get_resource_usage()
144149

0 commit comments

Comments
 (0)