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): document python FeatureFlagsIntegration for custom flag tracking #12152

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions docs/platforms/python/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ Evaluation tracking requires enabling an SDK integration. Integrations are provi

- [OpenFeature](/platforms/python/integrations/openfeature/)
- [LaunchDarkly](/platforms/python/integrations/launchdarkly/)
- [Manual Tracking](/platforms/python/integrations/feature_flags/) - if you use an unsupported or in-house provider, you may track evaluations through an API.

<PlatformContent includePath="feature-flags/enable-change-tracking" />
50 changes: 50 additions & 0 deletions docs/platforms/python/integrations/feature_flags/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Feature Flags
description: "Learn how to attach custom feature flag data to Sentry error events."
---

<PlatformContent includePath="feature-flags/prerelease-alert" />

The Feature Flags integration allows you to manually track feature flag evaluations through an API. These evaluations are held in memory, and in the event an error occurs, sent to Sentry for review and analysis.
**At the moment, we only support boolean flag evaluations.**

## Install

Install `sentry-sdk` (>=TODO:) from PyPI.

```bash
pip install --upgrade 'sentry-sdk'
```

## Configure

Add `FeatureFlagsIntegration()` to your `integrations` list:

```python
import sentry_sdk
from sentry_sdk.integrations.feature_flags import FeatureFlagsIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
FeatureFlagsIntegration(),
],
)
```

## Verify

The integration is tested by calling the `add_feature_flag` API before capturing an exception.

```python
import sentry_sdk
from sentry_sdk.integrations.feature_flags import add_feature_flag

add_feature_flag('test-flag', False)

sentry_sdk.capture_exception(Exception("Something went wrong!"))
```

Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag" and its value "false".

<PlatformContent includePath="feature-flags/next-steps" />
1 change: 1 addition & 0 deletions docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
| ----------------------------------------------------------------------------------------------------------------------- | :--------------: |
| <LinkWithPlatformIcon platform="python" label="LaunchDarkly" url="/platforms/python/integrations/launchdarkly" /> | |
| <LinkWithPlatformIcon platform="python" label="OpenFeature" url="/platforms/python/integrations/openfeature" /> | |
| <LinkWithPlatformIcon platform="python" label="Feature Flags Manual Tracking" url="/platforms/python/integrations/feature_flags" /> | |

### Cloud Computing

Expand Down
Loading