From 4e06a504c43bdda0bb7f742c31bb6fb1306b1d0b Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 1 Oct 2025 17:23:01 -0500 Subject: [PATCH] Onyl clear logcontext if spans should finish --- synapse/logging/scopecontextmanager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/synapse/logging/scopecontextmanager.py b/synapse/logging/scopecontextmanager.py index feaadc4d87..4c3cc109b2 100644 --- a/synapse/logging/scopecontextmanager.py +++ b/synapse/logging/scopecontextmanager.py @@ -155,7 +155,9 @@ class _LogContextScope(Scope): if self._finish_on_close: self.span.finish() - self.logcontext.scope = None + # The tracing scope/span should stick to the logcontext if it's active + # so we only clear if we're finishing the span. + self.logcontext.scope = None if self._enter_logcontext: self.logcontext.__exit__(None, None, None)