From 81c17617efb26419673cbae4c1a9de8bbfbd5f9c Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:20:40 -0800 Subject: [PATCH] Rename to add_feature_flag --- sentry_sdk/integrations/featureflags.py | 6 +++--- .../featureflags/test_featureflags.py | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sentry_sdk/integrations/featureflags.py b/sentry_sdk/integrations/featureflags.py index 669341bb6e..b13dfc03e8 100644 --- a/sentry_sdk/integrations/featureflags.py +++ b/sentry_sdk/integrations/featureflags.py @@ -16,11 +16,11 @@ class FeatureFlagsIntegration(Integration): @example ``` import sentry_sdk - from sentry_sdk.integrations.featureflags import FeatureFlagsIntegration, add_flag + from sentry_sdk.integrations.featureflags import FeatureFlagsIntegration, add_feature_flag sentry_sdk.init(dsn="my_dsn", integrations=[FeatureFlagsIntegration()]); - add_flag('my-flag', true); + add_feature_flag('my-flag', true); sentry_sdk.capture_exception(Exception('broke')); // 'my-flag' should be captured on this Sentry event. ``` """ @@ -33,7 +33,7 @@ def setup_once(): scope.add_error_processor(flag_error_processor) -def add_flag(flag: str, result: bool): +def add_feature_flag(flag: str, result: bool): """ Records a flag and its value to be sent on subsequent error events. We recommend you do this on flag evaluations. Flags are buffered per Sentry scope and limited to 100 per event. diff --git a/tests/integrations/featureflags/test_featureflags.py b/tests/integrations/featureflags/test_featureflags.py index 4677870d50..29d7026a66 100644 --- a/tests/integrations/featureflags/test_featureflags.py +++ b/tests/integrations/featureflags/test_featureflags.py @@ -5,7 +5,10 @@ import sentry_sdk from sentry_sdk.integrations import _processed_integrations, _installed_integrations -from sentry_sdk.integrations.featureflags import FeatureFlagsIntegration, add_flag +from sentry_sdk.integrations.featureflags import ( + FeatureFlagsIntegration, + add_feature_flag, +) @pytest.fixture @@ -23,9 +26,9 @@ def test_featureflags_integration(sentry_init, capture_events, uninstall_integra uninstall_integration(FeatureFlagsIntegration.identifier) sentry_init(integrations=[FeatureFlagsIntegration()]) - add_flag("hello", False) - add_flag("world", True) - add_flag("other", False) + add_feature_flag("hello", False) + add_feature_flag("world", True) + add_feature_flag("other", False) events = capture_events() sentry_sdk.capture_exception(Exception("something wrong!")) @@ -48,13 +51,13 @@ def test_featureflags_integration_threaded( events = capture_events() # Capture an eval before we split isolation scopes. - add_flag("hello", False) + add_feature_flag("hello", False) def task(flag_key): # Creates a new isolation scope for the thread. # This means the evaluations in each task are captured separately. with sentry_sdk.isolation_scope(): - add_flag(flag_key, False) + add_feature_flag(flag_key, False) # use a tag to identify to identify events later on sentry_sdk.set_tag("task_id", flag_key) sentry_sdk.capture_exception(Exception("something wrong!")) @@ -97,13 +100,13 @@ def test_featureflags_integration_asyncio( events = capture_events() # Capture an eval before we split isolation scopes. - add_flag("hello", False) + add_feature_flag("hello", False) async def task(flag_key): # Creates a new isolation scope for the thread. # This means the evaluations in each task are captured separately. with sentry_sdk.isolation_scope(): - add_flag(flag_key, False) + add_feature_flag(flag_key, False) # use a tag to identify to identify events later on sentry_sdk.set_tag("task_id", flag_key) sentry_sdk.capture_exception(Exception("something wrong!"))