Skip to content
Closed
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/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` (>=TODO:) from PyPI.
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO after release!


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

## Configure

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

```python
import sentry_sdk
from sentry_sdk.integrations.featureflags import FeatureFlagsIntegration
Copy link
Member

Choose a reason for hiding this comment

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

The module's name need to be feature_flags. Spaces are rendered as underscores in Python module names. This needs to be fixed within the SDK code. You can keep the featureflags module for backwards compatibility reasons but we shouldn't document it. We probably don't need the backwards compatibility any way as I doubt anyone's using it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Spaces are rendered as underscores in Python module names. This needs to be fixed within the SDK code.

What code are you referring to? Where do we have "feature flags"?

Copy link
Member Author

Choose a reason for hiding this comment

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


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" />
7 changes: 4 additions & 3 deletions docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
| <LinkWithPlatformIcon platform="python.rq" label="RQ" url="/platforms/python/integrations/rq" /> | ✓ |
| <LinkWithPlatformIcon platform="python.ray" label="Ray" url="/platforms/python/integrations/ray" /> | |

## Feature Flags
### Feature Flags

| | **Auto-enabled** |
| ----------------------------------------------------------------------------------------------------------------------- | :--------------: |
| <LinkWithPlatformIcon platform="launchdarkly" label="LaunchDarkly" url="/platforms/python/integrations/launchdarkly" /> | |
| <LinkWithPlatformIcon platform="openfeature" label="OpenFeature" url="/platforms/python/integrations/openfeature" /> | |
| <LinkWithPlatformIcon platform="python" label="LaunchDarkly" url="/platforms/python/integrations/launchdarkly" /> | |
| <LinkWithPlatformIcon platform="python" label="OpenFeature" url="/platforms/python/integrations/openfeature" /> | |
| <LinkWithPlatformIcon platform="python" label="FeatureFlags (Manual Tracking)" url="/platforms/python/integrations/featureflags" /> | |

### Cloud Computing

Expand Down
Loading