Skip to content

Commit 4b81e30

Browse files
aliu39antonpirker
andauthored
feat(flags): re-publish docs on python unleash and generic integrations (#12300)
This PR re-publishes them and - fixes Unleash sample code (need to call `initialize_client()`) and versioning. - moves python generic docs, after changing it from an integration to an API: getsentry/sentry-python#3917 --------- Co-authored-by: Anton Pirker <[email protected]>
1 parent c81d6f0 commit 4b81e30

File tree

9 files changed

+113
-16
lines changed

9 files changed

+113
-16
lines changed

docs/organization/integrations/feature-flag/generic/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ To set up evaluation tracking, visit the [explore page](/product/explore/feature
1414

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

1819
## Change Tracking
1920

docs/organization/integrations/feature-flag/unleash/index.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ description: Learn about Sentry's Unleash integrations.
66

77
## Evaluation Tracking
88

9-
Support for this is coming soon, starting with [Python sentry-sdk](https://pypi.org/project/sentry-sdk/).
9+
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).
10+
11+
### Set Up Evaluation Tracking
12+
13+
To set up evaluation tracking, visit one of our supported languages pages:
14+
* [Python](/platforms/python/integrations/feature-flags/unleash/)
1015

1116
## Change Tracking
1217

@@ -20,7 +25,7 @@ Enabling Change Tracking is a three-step process. To get started visit the [feat
2025
- One webhook secret can be registered per provider type.
2126
- Select Unleash in the dropdown that says "Select a provider".
2227
2. **Register the webhook URL**.
23-
- 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.
28+
- 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.
2429
- Select the Webhook option. You should be on the `/integrations/create/webhook/` page.
2530
- Copy the provided Sentry webhook URL in settings and paste it into Unleash within their webhook integration UI.
2631
- Make sure the integration is toggled to Enabled.

docs/platforms/javascript/common/feature-flags/index.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your
3131
## Enable Evaluation Tracking
3232

3333
Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below.
34-
- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/)
35-
- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/)
34+
3635
- [Generic](/platforms/javascript/configuration/integrations/generic/)
36+
- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/)
37+
- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/)
3738

3839
<PlatformContent includePath="feature-flags/enable-change-tracking" />
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
11
---
22
title: Set Up Feature Flags
33
sidebar_order: 7000
4-
description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log feature flag changes, and reports any suspicious updates that may have caused an error.
4+
description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log of feature flag changes, and reports any suspicious updates that may have caused an error.
55
---
66

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

9+
A feature flagging integration allows you to manually track feature flag evaluations through an API. These evaluations are collected in memory, and in the event an error occurs, sent to Sentry for review and analysis.
10+
11+
912
## Prerequisites
1013

1114
* You have the <PlatformLink to="/">Python SDK installed</PlatformLink>.
1215

1316
## Enable Evaluation Tracking
1417

15-
Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below.
18+
Evaluation tracking typically requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below.
19+
20+
- [Generic (API)](/platforms/python/feature-flags/#generic-api)
21+
- [LaunchDarkly](/platforms/python/integrations/launchdarkly/)
22+
- [OpenFeature](/platforms/python/integrations/openfeature/)
23+
- [Unleash](/platforms/python/integrations/unleash/)
24+
25+
### Generic API
26+
The generic API allows you to manually track feature flag evaluations. These
27+
evaluations are held in memory, and in the event an error occurs, sent to
28+
Sentry for review and analysis. Specifically, the generic integration enables
29+
users to integrate with proprietary (or otherwise unsupported) feature flagging
30+
solutions. **At the moment, we only support boolean flag evaluations.**
31+
32+
```python
33+
from sentry_sdk.feature_flags import add_feature_flag
34+
35+
add_feature_flag('test-flag', False) # Records an evaluation and its result.
36+
37+
sentry_sdk.capture_exception(Exception("Something went wrong!"))
38+
```
1639

17-
- [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/)
18-
- [LaunchDarkly](/platforms/python/integrations/feature-flags/launchdarkly/)
40+
Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
1941

2042
<PlatformContent includePath="feature-flags/enable-change-tracking" />

docs/platforms/python/integrations/feature-flags/index.mdx

Lines changed: 0 additions & 8 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Unleash
3+
description: "Learn how to use Sentry with Unleash."
4+
---
5+
6+
<PlatformContent includePath="feature-flags/prerelease-alert" />
7+
8+
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.**
9+
10+
## Install
11+
12+
Install `sentry-sdk` (>=2.20.0) and `UnleashClient` (>=6.0.1) from PyPI.
13+
14+
```bash
15+
pip install --upgrade sentry-sdk UnleashClient
16+
```
17+
18+
## Configure
19+
20+
Add `UnleashIntegration` to your `integrations` list:
21+
22+
```python
23+
import sentry_sdk
24+
from sentry_sdk.integrations.unleash import UnleashIntegration
25+
26+
sentry_sdk.init(
27+
dsn="___PUBLIC_DSN___",
28+
integrations=[UnleashIntegration()],
29+
)
30+
```
31+
32+
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).
33+
34+
## Verify
35+
36+
Test the integration by evaluating a feature flag using your Unleash SDK before capturing an exception.
37+
38+
```python {tabTitle: Python, using is_enabled}
39+
import sentry_sdk
40+
from UnleashClient import UnleashClient
41+
42+
unleash = UnleashClient(...) # See Unleash quickstart.
43+
unleash.initialize_client()
44+
45+
test_flag_enabled = unleash.is_enabled("test-flag")
46+
sentry_sdk.capture_exception(Exception("Something went wrong!"))
47+
```
48+
49+
```python {tabTitle: Python, using get_variant}
50+
import sentry_sdk
51+
from UnleashClient import UnleashClient
52+
53+
unleash = UnleashClient(...) # See Unleash quickstart.
54+
unleash.initialize_client()
55+
56+
test_flag_variant = unleash.get_variant("test-flag")
57+
test_flag_enabled = test_flag_variant["enabled"]
58+
sentry_sdk.capture_exception(Exception("Something went wrong!"))
59+
```
60+
61+
Visit the [Sentry website](https://sentry.io/issues/) and confirm that your error
62+
event has recorded the feature flag "test-flag", and its value is equal to `test_flag_enabled`.
63+
64+
<PlatformContent includePath="feature-flags/next-steps" />

src/middleware.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,18 @@ const USER_DOCS_REDIRECTS: Redirect[] = [
505505
from: '/platforms/python/tryton/',
506506
to: '/platforms/python/integrations/tryton/',
507507
},
508+
{
509+
from: '/platforms/python/integrations/feature-flags/launchdarkly/',
510+
to: '/platforms/python/integrations/launchdarkly/',
511+
},
512+
{
513+
from: '/platforms/python/integrations/feature-flags/openfeature/',
514+
to: '/platforms/python/integrations/openfeature/',
515+
},
516+
{
517+
from: '/platforms/python/integrations/feature-flags/unleash/',
518+
to: '/platforms/python/integrations/unleash/',
519+
},
508520
{
509521
from: '/clients/python/breadcrumbs/',
510522
to: '/platforms/python/legacy-sdk/breadcrumbs/',

0 commit comments

Comments
 (0)