Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(flags): add Statsig integration #4022

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feat(flags): add Statsig integration #4022

wants to merge 1 commit into from

Conversation

aliu39
Copy link
Member

@aliu39 aliu39 commented Feb 8, 2025

New integration for tracking Statsig (pypi) flag evaluations, specifically the checkGate method which is used for boolean release flags. Unlike JS, there's no support for event callbacks for Statsig's server SDKs. Instead we wrap the module-level check_gate function.

Ref https://develop.sentry.dev/sdk/expected-features/#feature-flags

Ref

Copy link

codecov bot commented Feb 8, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
22143 1 22142 5782
View the full list of 1 ❄️ flaky tests
tests.integrations.stdlib.test_httplib test_http_timeout

Flake rate in main: 69.03% (Passed 35 times, Failed 78 times)

Stack Traces | 0.188s run time
.../integrations/stdlib/test_httplib.py:373: in test_http_timeout
    assert len(transaction["spans"]) == 1
E   assert 0 == 1
E    +  where 0 = len([])

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@aliu39 aliu39 added the New Integration Integrating with a new framework or library label Feb 8, 2025
Comment on lines +34 to +35
flags = sentry_sdk.get_current_scope().flags
flags.set(gate, enabled)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a function for this:

def add_feature_flag(flag, result):

import importlib

try:
# The statsig package has the same name as this file. We use importlib to avoid conflicts.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't an issue in the openfeature integration:

try:
from openfeature import api
from openfeature.hook import Hook
if TYPE_CHECKING:
from openfeature.flag_evaluation import FlagEvaluationDetails
from openfeature.hook import HookContext, HookHints
except ImportError:
raise DidNotEnable("OpenFeature is not installed")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Integration Integrating with a new framework or library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants