Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
7 changes: 4 additions & 3 deletions docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
| <LinkWithPlatformIcon platform="python.rq" label="RQ" url="/platforms/python/integrations/rq" /> | ✓ |
| <LinkWithPlatformIcon platform="python.ray" label="Ray" url="/platforms/python/integrations/ray" /> | |

## Feature Flags
### Feature Flags

| | **Auto-enabled** |
| ----------------------------------------------------------------------------------------------------------------------- | :--------------: |
| <LinkWithPlatformIcon platform="launchdarkly" label="LaunchDarkly" url="/platforms/python/integrations/launchdarkly" /> | |
| <LinkWithPlatformIcon platform="openfeature" label="OpenFeature" url="/platforms/python/integrations/openfeature" /> | |
| <LinkWithPlatformIcon platform="python" label="LaunchDarkly" url="/platforms/python/integrations/launchdarkly" /> | |
| <LinkWithPlatformIcon platform="python" label="OpenFeature" url="/platforms/python/integrations/openfeature" /> | |
| <LinkWithPlatformIcon platform="python" label="Unleash" url="/platforms/python/integrations/unleash" /> | |

### Cloud Computing

Expand Down
73 changes: 73 additions & 0 deletions docs/platforms/python/integrations/unleash/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
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` (>=TODO:) 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
from UnleashClient import UnleashClient

unleash_client = UnleashClient(
url="<Unleash server URL>/api/", # "http://localhost:4242/api/" if you are self-hosting Unleash
app_name="my-app", # Identifies your app in the Unleash UI
custom_headers={
"Authorization": os.environ["UNLEASH_CLIENT_API_TOKEN"] # See 'client token' docs
}
)

unleash_integration = UnleashIntegration(unleash_client)

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

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

The integration is tested by evaluating a feature flag using your Unleash SDK before capturing an exception.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The integration is tested by evaluating a feature flag using your Unleash SDK before capturing an exception.
Test the integration by evaluating a feature flag using your Unleash SDK before capturing an exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

This would apply to other python FF docs too


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

# Re-use `unleash_client` from the previous step.
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

# Re-use `unleash_client` from the previous step.
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 and confirm that your error event has recorded the feature flag "test-flag", and its value
is equal to `test_flag_enabled`.
Copy link
Member

Choose a reason for hiding this comment

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

a link into /issues would be good here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above, this would apply to other python FF docs too


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