-
Notifications
You must be signed in to change notification settings - Fork 35
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
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ed24cb8
Fix warning deprecated function sentry_sdk.configure_scope in version…
spous-ovl d6ff0b3
Fix
spous-ovl f6c8331
Fix
spous-ovl 7b4055d
Fix black
spous-ovl 7ef6fcc
Update libs with poetry new sentry-sdk version 2.13.0
spous-ovl 38da474
Fix test for version 2.13.0 sentry-sdk
spous-ovl 02cfed4
Fix double quoted strings
spous-ovl 82e7fa0
Fix versioning
spous-ovl f052d7a
Fix isort
spous-ovl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,11 @@ 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 | ||
|
||
with configure_scope() as scope: | ||
if sentry_sdk.VERSION >= '2.12.0': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might want to be careful when comparing strings here: >>> "2.2.0" >= "2.12.0"
True There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx, already fixed |
||
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) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 2.12.0 the version where the warning was added, or when the
get_isolation_scope
function was added? It seems like it would be best to use the version whereget_isolation_scope
was added, doesn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method
get_isolation_scope
was added in 2.0 but only in the class Scope, it wasn't added in the init.py, that means we must usesentry_sdk.Scope.get_isolation_scope()
to use the method. The warning and the function was added in init.py in version 2.12, that's why I did this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check it here:
Added in
__init__.py
2.12: https://github.com/getsentry/sentry-python/blob/2.12.0/sentry_sdk/__init__.pyDoesn't added in
__init__.py
version less than or equal to 2.11: https://github.com/getsentry/sentry-python/blob/2.11.0/sentry_sdk/__init__.pyAdded in 2.0 but without the warning and also without being added the symbol in the var
__all__
in the__init__.py
file (there is also a symbol called isolation_scope in the var__all__
but it's not even a method): https://github.com/getsentry/sentry-python/blob/2.0.0/sentry_sdk/scope.py#L273Added warning in 2.12 here: https://github.com/getsentry/sentry-python/blob/2.12.0/sentry_sdk/api.py#L223