@@ -31,6 +31,63 @@ def test_featureflags_integration(sentry_init, capture_events, uninstall_integra
31
31
}
32
32
33
33
34
+ @pytest .mark .asyncio
35
+ async def test_featureflags_integration_spans_async (sentry_init , capture_events ):
36
+ sentry_init (
37
+ traces_sample_rate = 1.0 ,
38
+ )
39
+ events = capture_events ()
40
+
41
+ add_feature_flag ("hello" , False )
42
+
43
+ try :
44
+ with sentry_sdk .start_span (name = "test-span" ):
45
+ with sentry_sdk .start_span (name = "test-span-2" ):
46
+ raise ValueError ("something wrong!" )
47
+ except ValueError as e :
48
+ sentry_sdk .capture_exception (e )
49
+
50
+ found = False
51
+ for event in events :
52
+ if "exception" in event .keys ():
53
+ assert event ["contexts" ]["flags" ] == {
54
+ "values" : [
55
+ {"flag" : "hello" , "result" : False },
56
+ ]
57
+ }
58
+ found = True
59
+
60
+ assert found , "No event with exception found"
61
+
62
+
63
+ def test_featureflags_integration_spans_sync (sentry_init , capture_events ):
64
+ sentry_init (
65
+ traces_sample_rate = 1.0 ,
66
+ )
67
+ events = capture_events ()
68
+
69
+ add_feature_flag ("hello" , False )
70
+
71
+ try :
72
+ with sentry_sdk .start_span (name = "test-span" ):
73
+ with sentry_sdk .start_span (name = "test-span-2" ):
74
+ raise ValueError ("something wrong!" )
75
+ except ValueError as e :
76
+ sentry_sdk .capture_exception (e )
77
+
78
+ found = False
79
+ for event in events :
80
+ if "exception" in event .keys ():
81
+ assert event ["contexts" ]["flags" ] == {
82
+ "values" : [
83
+ {"flag" : "hello" , "result" : False },
84
+ ]
85
+ }
86
+ found = True
87
+
88
+ assert found , "No event with exception found"
89
+
90
+
34
91
def test_featureflags_integration_threaded (
35
92
sentry_init , capture_events , uninstall_integration
36
93
):
0 commit comments