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

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

Merged
merged 2 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10183.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add debug logging for when we enter and exit `Measure` blocks.
5 changes: 5 additions & 0 deletions synapse/util/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,17 @@ def __enter__(self) -> "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()

Expand Down