Skip to content

Commit

Permalink
Rename to add_feature_flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aliu39 committed Dec 6, 2024
1 parent 36bc869 commit 81c1761
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/featureflags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```
"""
Expand All @@ -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.
Expand Down
19 changes: 11 additions & 8 deletions tests/integrations/featureflags/test_featureflags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!"))
Expand All @@ -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!"))
Expand Down Expand Up @@ -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!"))
Expand Down

0 comments on commit 81c1761

Please sign in to comment.