Skip to content

Commit 54a6fa3

Browse files
aliu39antonpirkercmanallen
authored andcommitted
feat(flags): document python UnleashIntegration (#12216)
* feat(flags): document python UnleashIntegration * ref versioning note * Reword note on get_variant * get_variant example * import os * Move to integrations folder * Add to integrations index * Review comments * Update docs/platforms/python/integrations/unleash/index.mdx Co-authored-by: Colton Allen <cmanallen90@gmail.com> * Fix merge conflict * Remove unnecessary documentation of unleash client initialization * Remove os import * Add unleash imports --------- Co-authored-by: Anton Pirker <anton.pirker@sentry.io> Co-authored-by: Colton Allen <cmanallen90@gmail.com> Co-authored-by: Colton Allen <colton.allen@sentry.io>
1 parent 52b2483 commit 54a6fa3

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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.19.3) 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_client = UnleashClient(...) # See Unleash quickstart.
43+
test_flag_enabled = unleash_client.is_enabled("test-flag")
44+
45+
sentry_sdk.capture_exception(Exception("Something went wrong!"))
46+
```
47+
48+
```python {tabTitle: Python, using get_variant}
49+
import sentry_sdk
50+
from UnleashClient import UnleashClient
51+
52+
unleash_client = UnleashClient(...) # See Unleash quickstart.
53+
test_flag_variant = unleash_client.get_variant("test-flag")
54+
test_flag_enabled = test_flag_variant["enabled"]
55+
56+
sentry_sdk.capture_exception(Exception("Something went wrong!"))
57+
```
58+
59+
Visit the [Sentry website](https://sentry.io/issues/) and confirm that your error
60+
event has recorded the feature flag "test-flag", and its value is equal to `test_flag_enabled`.
61+
62+
<PlatformContent includePath="feature-flags/next-steps" />

docs/platforms/python/integrations/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
6565
| ----------------------------------------------------------------------------------------------------------------------- | :--------------: |
6666
| <LinkWithPlatformIcon platform="python" label="LaunchDarkly" url="/platforms/python/integrations/feature-flags/launchdarkly" /> | |
6767
| <LinkWithPlatformIcon platform="python" label="OpenFeature" url="/platforms/python/integrations/feature-flags/openfeature" /> | |
68+
| <LinkWithPlatformIcon platform="python" label="Unleash" url="/platforms/python/integrations/feature-flags/unleash" /> | |
6869

6970
### Cloud Computing
7071

0 commit comments

Comments
 (0)