Skip to content

Commit

Permalink
Fix deprectation warning for sentry-sdk 2.x (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
imSniff authored Sep 2, 2024
1 parent c03d92e commit 58e81e9
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 599 deletions.
9 changes: 7 additions & 2 deletions asgi_correlation_id/extensions/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def set_transaction_id(correlation_id: str) -> None:
The transaction ID is displayed in a Sentry event's detail view,
which makes it easier to correlate logs to specific events.
"""
from sentry_sdk import configure_scope
import sentry_sdk
from packaging import version

with configure_scope() as scope:
if version.parse(sentry_sdk.VERSION) >= version.parse('2.12.0'):
scope = sentry_sdk.get_isolation_scope()
scope.set_tag('transaction_id', correlation_id)
else:
with sentry_sdk.configure_scope() as scope:
scope.set_tag('transaction_id', correlation_id)
Loading

0 comments on commit 58e81e9

Please sign in to comment.