Skip to content

Commit 58e81e9

Browse files
authored
Fix deprectation warning for sentry-sdk 2.x (#95)
1 parent c03d92e commit 58e81e9

File tree

3 files changed

+145
-599
lines changed

3 files changed

+145
-599
lines changed

asgi_correlation_id/extensions/sentry.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ def set_transaction_id(correlation_id: str) -> None:
2222
The transaction ID is displayed in a Sentry event's detail view,
2323
which makes it easier to correlate logs to specific events.
2424
"""
25-
from sentry_sdk import configure_scope
25+
import sentry_sdk
26+
from packaging import version
2627

27-
with configure_scope() as scope:
28+
if version.parse(sentry_sdk.VERSION) >= version.parse('2.12.0'):
29+
scope = sentry_sdk.get_isolation_scope()
2830
scope.set_tag('transaction_id', correlation_id)
31+
else:
32+
with sentry_sdk.configure_scope() as scope:
33+
scope.set_tag('transaction_id', correlation_id)

0 commit comments

Comments
 (0)