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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/platforms/python/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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/javascript/configuration/integrations/featureflags/) - if you use an unsupported or in-house provider, you may track evaluations through an API.
- [Manual Tracking](/platforms/python/integrations/featureflags/) - 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/featureflags/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` from PyPI.

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

## Configure

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

```python
import sentry_sdk
from sentry_sdk.integrations.featureflags 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.featureflags 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" />
Loading