5
5
6
6
import sentry_sdk
7
7
from sentry_sdk .integrations import _processed_integrations , _installed_integrations
8
- from sentry_sdk .integrations .featureflags import FeatureFlagsIntegration
8
+ from sentry_sdk .integrations .featureflags import FeatureFlagsIntegration , add_flag
9
9
10
10
11
11
@pytest .fixture
@@ -22,11 +22,10 @@ def inner(identifier):
22
22
def test_featureflags_integration (sentry_init , capture_events , uninstall_integration ):
23
23
uninstall_integration (FeatureFlagsIntegration .identifier )
24
24
sentry_init (integrations = [FeatureFlagsIntegration ()])
25
- flags_integration = sentry_sdk .get_client ().get_integration (FeatureFlagsIntegration )
26
25
27
- flags_integration . set_flag ("hello" , False )
28
- flags_integration . set_flag ("world" , True )
29
- flags_integration . set_flag ("other" , False )
26
+ add_flag ("hello" , False )
27
+ add_flag ("world" , True )
28
+ add_flag ("other" , False )
30
29
31
30
events = capture_events ()
32
31
sentry_sdk .capture_exception (Exception ("something wrong!" ))
@@ -49,17 +48,13 @@ def test_featureflags_integration_threaded(
49
48
events = capture_events ()
50
49
51
50
# Capture an eval before we split isolation scopes.
52
- flags_integration = sentry_sdk .get_client ().get_integration (FeatureFlagsIntegration )
53
- flags_integration .set_flag ("hello" , False )
51
+ add_flag ("hello" , False )
54
52
55
53
def task (flag_key ):
56
54
# Creates a new isolation scope for the thread.
57
55
# This means the evaluations in each task are captured separately.
58
56
with sentry_sdk .isolation_scope ():
59
- flags_integration = sentry_sdk .get_client ().get_integration (
60
- FeatureFlagsIntegration
61
- )
62
- flags_integration .set_flag (flag_key , False )
57
+ add_flag (flag_key , False )
63
58
# use a tag to identify to identify events later on
64
59
sentry_sdk .set_tag ("task_id" , flag_key )
65
60
sentry_sdk .capture_exception (Exception ("something wrong!" ))
@@ -102,17 +97,13 @@ def test_featureflags_integration_asyncio(
102
97
events = capture_events ()
103
98
104
99
# Capture an eval before we split isolation scopes.
105
- flags_integration = sentry_sdk .get_client ().get_integration (FeatureFlagsIntegration )
106
- flags_integration .set_flag ("hello" , False )
100
+ add_flag ("hello" , False )
107
101
108
102
async def task (flag_key ):
109
103
# Creates a new isolation scope for the thread.
110
104
# This means the evaluations in each task are captured separately.
111
105
with sentry_sdk .isolation_scope ():
112
- flags_integration = sentry_sdk .get_client ().get_integration (
113
- FeatureFlagsIntegration
114
- )
115
- flags_integration .set_flag (flag_key , False )
106
+ add_flag (flag_key , False )
116
107
# use a tag to identify to identify events later on
117
108
sentry_sdk .set_tag ("task_id" , flag_key )
118
109
sentry_sdk .capture_exception (Exception ("something wrong!" ))
0 commit comments