Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprectated warning for function sentry_sdk.configure_scope, fix migration for sentry-sdk 2.x #95

Merged
merged 9 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading