Skip to content

Commit

Permalink
fix: Sentry scope migration for 2.x (#129)
Browse files Browse the repository at this point in the history
* [BUG] Sentry scope migration fo 2.x

migrate scope usage to v2.x
more info https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring

* bump sentry version

* update scope logic to allow older versions

* Update sentry.py

lint

* Update sentry.py

* fix logger
  • Loading branch information
pedroserrudo authored Sep 23, 2024
1 parent cf849e3 commit e57f044
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions django_guid/integrations/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def run(self, guid: str, **kwargs: Any) -> None:
"""
import sentry_sdk

with sentry_sdk.configure_scope() as scope:
logger.debug('Setting Sentry transaction_id to %s', guid)
scope.set_tag('transaction_id', guid)
if sentry_sdk.VERSION >= '2.0.0':
with sentry_sdk.isolation_scope() as scope:
scope.set_tag('transaction_id', guid)
else:
with sentry_sdk.configure_scope() as scope:
scope.set_tag('transaction_id', guid)

logger.debug(f'Setting Sentry transaction_id to {guid}')

0 comments on commit e57f044

Please sign in to comment.