-
Notifications
You must be signed in to change notification settings - Fork 550
Fix last_event_id() in nested scopes #3114
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,9 +208,6 @@ def __init__(self, ty=None, client=None): | |
incoming_trace_information = self._load_trace_data_from_env() | ||
self.generate_propagation_context(incoming_data=incoming_trace_information) | ||
|
||
# self._last_event_id is only applicable to isolation scopes | ||
self._last_event_id = None # type: Optional[str] | ||
|
||
def __copy__(self): | ||
# type: () -> Scope | ||
""" | ||
|
@@ -244,6 +241,8 @@ def __copy__(self): | |
|
||
rv._profile = self._profile | ||
|
||
rv._last_event_id = self._last_event_id | ||
|
||
return rv | ||
|
||
@classmethod | ||
|
@@ -677,6 +676,9 @@ def clear(self): | |
|
||
self._propagation_context = None | ||
|
||
# self._last_event_id is only applicable to isolation scopes | ||
self._last_event_id = None # type: Optional[str] | ||
|
||
Comment on lines
+679
to
+681
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. Likely belongs in separate PR, see previous comment. |
||
@_attr_setter | ||
def level(self, value): | ||
# type: (LogLevelStr) -> None | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -800,3 +800,11 @@ def test_last_event_id_transaction(sentry_init): | |||||
pass | ||||||
|
||||||
assert last_event_id() is None, "Transaction should not set last_event_id" | ||||||
|
||||||
|
||||||
def test_last_event_id_scope(sentry_init): | ||||||
sentry_init(enable_tracing=True) | ||||||
|
||||||
# Should not crash | ||||||
with push_scope() as scope: | ||||||
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.
Suggested change
|
||||||
assert scope.last_event_id() is None |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,10 @@ def test_copying(): | |
s1.set_tag("foo", "bar") | ||
|
||
s2 = copy.copy(s1) | ||
# Check all attributes are copied | ||
for name in set(Scope.__slots__) - {"client"}: | ||
getattr(s2, name) | ||
|
||
Comment on lines
+28
to
+31
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. I would prefer to add this check to a separate unit test, since it is somewhat unrelated to the tag copying checks that this existing test is checking. The comment should also be updated to something like "Check that all attributes, except |
||
assert "foo" in s2._tags | ||
|
||
s1.set_tag("bam", "baz") | ||
|
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.
While I agree that it likely makes sense to move these lines to the
clear
function, I believe this change should be considered in a separate PR, since it does not appear to be needed to fix #3113; the tests you added pass even if I undo this change.