From 3ca5a2e6bb698ac4e48a0b9a837e5cb504dd1ef9 Mon Sep 17 00:00:00 2001 From: Alexander Presnyakov Date: Mon, 1 Sep 2025 17:10:03 +0000 Subject: [PATCH] Fixed Sentry transaction continuation --- cmapi/tracing/sentry_backend.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmapi/tracing/sentry_backend.py b/cmapi/tracing/sentry_backend.py index cb343fe5f..38ee5da20 100644 --- a/cmapi/tracing/sentry_backend.py +++ b/cmapi/tracing/sentry_backend.py @@ -82,8 +82,10 @@ class SentryBackend(TracerBackend): @swallow_exceptions def on_incoming_request(self, headers: Dict[str, str], method: str, path: str) -> None: name = f"{method} {path}" if method or path else "http.server" - transaction = sentry_sdk.continue_trace(headers or {}, op='http.server', name=name) - # Store transaction in context var to ensure we can finish it later + # Continue from incoming headers, then START the transaction per SDK v2 + continued = sentry_sdk.continue_trace(headers or {}, op='http.server', name=name) + transaction = sentry_sdk.start_transaction(transaction=continued) + # Store started transaction in context var and make current (enter) self._current_transaction.set(transaction) transaction.__enter__() scope = sentry_sdk.Hub.current.scope