-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(flags): document python UnleashIntegration #12216
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fe943f6
feat(flags): document python UnleashIntegration
aliu39 f5ecd05
ref versioning note
aliu39 f91ef93
Reword note on get_variant
aliu39 92ed334
get_variant example
aliu39 09b3ff6
import os
aliu39 2c5e06c
Move to integrations folder
aliu39 4c72a14
Add to integrations index
aliu39 64ccd98
Review comments
aliu39 ac250c5
Merge branch 'master' into aliu/unleash
aliu39 61ec075
Update docs/platforms/python/integrations/unleash/index.mdx
antonpirker a4f66f4
Merge branch 'master' into aliu/unleash
cmanallen 8550c48
Fix merge conflict
cmanallen 0c32482
Remove unnecessary documentation of unleash client initialization
cmanallen a0d849b
Remove os import
cmanallen d405816
Add unleash imports
cmanallen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
docs/platforms/python/integrations/feature-flags/unleash.mdx
This file contains hidden or 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,60 @@ | ||
--- | ||
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 | ||
import os | ||
|
||
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 | ||
|
||
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 | ||
|
||
cmanallen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.