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): re-publish docs on python unleash and generic integrations #12300

Merged
merged 6 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To set up evaluation tracking, visit the [explore page](/product/explore/feature

To set up generic evaluation tracking, visit one of our supported languages' pages:
* [JavaScript](/platforms/javascript/configuration/integrations/generic/)
* [Python](/platforms/python/integrations/feature-flags/generic/)

## Change Tracking

Expand Down
9 changes: 7 additions & 2 deletions docs/organization/integrations/feature-flag/unleash/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ description: Learn about Sentry's Unleash integrations.

## Evaluation Tracking

Support for this is coming soon, starting with [Python sentry-sdk](https://pypi.org/project/sentry-sdk/).
Sentry can track flag evaluations as they happen within your application. Flag evaluations will appear in the "Feature Flag" section of the Issue Details page as a table, with "suspect" flag predictions highlighted in yellow. Learn more about how to interact with feature flag insights within the Sentry UI by reading the [Issue Details page documentation](/product/issues/issue-details/#feature-flags).

### Set Up Evaluation Tracking

To set up evaluation tracking, visit one of our supported languages pages:
* [Python](/platforms/python/integrations/feature-flags/unleash/)

## Change Tracking

Expand All @@ -20,7 +25,7 @@ Enabling Change Tracking is a three-step process. To get started visit the [feat
- One webhook secret can be registered per provider type.
- Select Unleash in the dropdown that says "Select a provider".
2. **Register the webhook URL**.
- Go to your Unleash homepage and navigate to the `/integrations/` page, which can be found by clicking Integrations on the left-hand sidebar navigation, under the Configure heading.
- Go to your Unleash homepage and navigate to the `/integrations/` page, which can be found by clicking Integrations on the left-hand sidebar navigation, under the Configure heading.
- Select the Webhook option. You should be on the `/integrations/create/webhook/` page.
- Copy the provided Sentry webhook URL in settings and paste it into Unleash within their webhook integration UI.
- Make sure the integration is toggled to Enabled.
Expand Down
2 changes: 2 additions & 0 deletions docs/platforms/python/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ Evaluation tracking requires enabling an SDK integration. Integrations are provi

- [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/)
- [LaunchDarkly](/platforms/python/integrations/feature-flags/launchdarkly/)
- [Unleash](/platforms/python/integrations/feature-flags/unleash/)
- [Generic](/platforms/python/integrations/feature-flags/generic/)

<PlatformContent includePath="feature-flags/enable-change-tracking" />
49 changes: 49 additions & 0 deletions docs/platforms/python/integrations/feature-flags/generic.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Generic
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make the title a little more descriptive here? Like 'Generic Feature Flags' or something like that? Same with the page title for 'Unleash', maybe 'Feature Flags using Unleash'?

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. Specifically, the generic integration enables users to integrate with proprietary (or otherwise unsupported) feature flagging solutions. **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.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!"))
```

Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false".

<PlatformContent includePath="feature-flags/next-steps" />
64 changes: 64 additions & 0 deletions docs/platforms/python/integrations/feature-flags/unleash.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Unleash
description: "Learn how to use Sentry with Unleash."
---

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

The [Unleash](https://www.getunleash.io/) integration tracks feature flag evaluations produced by the Unleash SDK. These evaluations are held in memory and sent to Sentry for review and analysis if an error occurs. **At the moment, we only support boolean flag evaluations.**

## Install

Install `sentry-sdk` (>=2.20.0) and `UnleashClient` (>=6.0.1) from PyPI.

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

## Configure

Add `UnleashIntegration` to your `integrations` list:

```python
import sentry_sdk
from sentry_sdk.integrations.unleash import UnleashIntegration

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

For more information on how to use Unleash, read Unleash's [Python reference](https://docs.getunleash.io/reference/sdks/python) and [quickstart guide](https://docs.getunleash.io/quickstart).

## Verify

Test the integration by evaluating a feature flag using your Unleash SDK before capturing an exception.

```python {tabTitle: Python, using is_enabled}
import sentry_sdk
from UnleashClient import UnleashClient

unleash = UnleashClient(...) # See Unleash quickstart.
unleash.initialize_client()

test_flag_enabled = unleash.is_enabled("test-flag")
sentry_sdk.capture_exception(Exception("Something went wrong!"))
```

```python {tabTitle: Python, using get_variant}
import sentry_sdk
from UnleashClient import UnleashClient

unleash = UnleashClient(...) # See Unleash quickstart.
unleash.initialize_client()

test_flag_variant = unleash.get_variant("test-flag")
test_flag_enabled = test_flag_variant["enabled"]
sentry_sdk.capture_exception(Exception("Something went wrong!"))
```

Visit the [Sentry website](https://sentry.io/issues/) and confirm that your error
event has recorded the feature flag "test-flag", and its value is equal to `test_flag_enabled`.

<PlatformContent includePath="feature-flags/next-steps" />
Loading