File tree 3 files changed +34
-0
lines changed
3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 33
33
"get_traceparent" ,
34
34
"is_initialized" ,
35
35
"isolation_scope" ,
36
+ "last_event_id" ,
36
37
"new_scope" ,
37
38
"push_scope" ,
38
39
"set_context" ,
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ def overload(x):
59
59
"get_traceparent" ,
60
60
"is_initialized" ,
61
61
"isolation_scope" ,
62
+ "last_event_id" ,
62
63
"new_scope" ,
63
64
"push_scope" ,
64
65
"set_context" ,
@@ -332,6 +333,16 @@ def start_transaction(
332
333
)
333
334
334
335
336
+ @scopemethod
337
+ def last_event_id ():
338
+ # type: () -> Optional[str]
339
+ """
340
+ See :py:meth:`sentry_sdk.Scope.last_event_id` documentation regarding
341
+ this method's limitations.
342
+ """
343
+ return Scope .last_event_id ()
344
+
345
+
335
346
def set_measurement (name , value , unit = "" ):
336
347
# type: (str, float, MeasurementUnit) -> None
337
348
transaction = Scope .get_current_scope ().transaction
Original file line number Diff line number Diff line change 15
15
capture_exception ,
16
16
capture_message ,
17
17
start_transaction ,
18
+ last_event_id ,
18
19
add_breadcrumb ,
19
20
Hub ,
20
21
Scope ,
@@ -778,3 +779,24 @@ def test_classmethod_tracing(sentry_init):
778
779
with patch_start_tracing_child () as fake_start_child :
779
780
assert instance_or_class .class_ (1 ) == (TracingTestClass , 1 )
780
781
assert fake_start_child .call_count == 1
782
+
783
+
784
+ def test_last_event_id (sentry_init ):
785
+ sentry_init (enable_tracing = True )
786
+
787
+ assert last_event_id () is None
788
+
789
+ capture_exception (Exception ("test" ))
790
+
791
+ assert last_event_id () is not None
792
+
793
+
794
+ def test_last_event_id_transaction (sentry_init ):
795
+ sentry_init (enable_tracing = True )
796
+
797
+ assert last_event_id () is None
798
+
799
+ with start_transaction (name = "test" ):
800
+ pass
801
+
802
+ assert last_event_id () is None , "Transaction should not set last_event_id"
You can’t perform that action at this time.
0 commit comments