-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> * Fix merge conflict * Remove unnecessary documentation of unleash client initialization * Remove os import * Add unleash imports --------- Co-authored-by: Anton Pirker <[email protected]> Co-authored-by: Colton Allen <[email protected]> Co-authored-by: Colton Allen <[email protected]>
- Loading branch information
1 parent
1b4568d
commit 9ae1c68
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
docs/platforms/python/integrations/feature-flags/unleash.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
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.19.3) 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_client = UnleashClient(...) # See Unleash quickstart. | ||
test_flag_enabled = unleash_client.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_client = UnleashClient(...) # See Unleash quickstart. | ||
test_flag_variant = unleash_client.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" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters