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

Commit d56f480

Browse files
authored
Fix logging context warnings due to common usage metrics setup (#14574)
`setup()` is run under the sentinel context manager, so we wrap the initial update in a background process. Before this change, Synapse would log two warnings on startup: Starting db txn 'count_daily_users' from sentinel context Starting db connection from sentinel context: metrics will be lost Signed-off-by: Sean Quah <[email protected]>
1 parent d748bbc commit d56f480

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

changelog.d/14574.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug introduced in Synapse 1.67.0 where two logging context warnings would be logged on startup.

synapse/metrics/common_usage_metrics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ async def get_metrics(self) -> CommonUsageMetrics:
5454

5555
async def setup(self) -> None:
5656
"""Keep the gauges for common usage metrics up to date."""
57-
await self._update_gauges()
57+
run_as_background_process(
58+
desc="common_usage_metrics_update_gauges", func=self._update_gauges
59+
)
5860
self._clock.looping_call(
5961
run_as_background_process,
6062
5 * 60 * 1000,

0 commit comments

Comments
 (0)