From 2402fdf41b12c084933e39efb2ce31a44893df85 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:22:39 -0800 Subject: [PATCH 1/5] Revert "fix(flags): unpublish docs on unreleased python integrations (#12296)" This reverts commit 6d3fd15d091399f38b2c0747ccc3f4f70ab21490. --- .../feature-flag/generic/index.mdx | 1 + .../feature-flag/unleash/index.mdx | 9 ++- docs/platforms/python/feature-flags/index.mdx | 2 + .../integrations/feature-flags/generic.mdx | 49 +++++++++++++++ .../integrations/feature-flags/unleash.mdx | 62 +++++++++++++++++++ 5 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 docs/platforms/python/integrations/feature-flags/generic.mdx create mode 100644 docs/platforms/python/integrations/feature-flags/unleash.mdx diff --git a/docs/organization/integrations/feature-flag/generic/index.mdx b/docs/organization/integrations/feature-flag/generic/index.mdx index d4311c5460c3b..bcf29e58d504b 100644 --- a/docs/organization/integrations/feature-flag/generic/index.mdx +++ b/docs/organization/integrations/feature-flag/generic/index.mdx @@ -14,6 +14,7 @@ To set up evaluation tracking, visit the [explore page](/product/explore/feature To set up generic evaluation tracking, visit one of our supported languages' pages: * [JavaScript](/platforms/javascript/configuration/integrations/generic/) +* [Python](/platforms/python/integrations/feature-flags/generic/) ## Change Tracking diff --git a/docs/organization/integrations/feature-flag/unleash/index.mdx b/docs/organization/integrations/feature-flag/unleash/index.mdx index 46e7da0fb69b7..f0168cb9b52cb 100644 --- a/docs/organization/integrations/feature-flag/unleash/index.mdx +++ b/docs/organization/integrations/feature-flag/unleash/index.mdx @@ -6,7 +6,12 @@ description: Learn about Sentry's Unleash integrations. ## Evaluation Tracking -Support for this is coming soon, starting with [Python sentry-sdk](https://pypi.org/project/sentry-sdk/). +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). + +### Set Up Evaluation Tracking + +To set up evaluation tracking, visit one of our supported languages pages: +* [Python](/platforms/python/integrations/feature-flags/unleash/) ## Change Tracking @@ -20,7 +25,7 @@ Enabling Change Tracking is a three-step process. To get started visit the [feat - One webhook secret can be registered per provider type. - Select Unleash in the dropdown that says "Select a provider". 2. **Register the webhook URL**. - - 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. + - 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. - Select the Webhook option. You should be on the `/integrations/create/webhook/` page. - Copy the provided Sentry webhook URL in settings and paste it into Unleash within their webhook integration UI. - Make sure the integration is toggled to Enabled. diff --git a/docs/platforms/python/feature-flags/index.mdx b/docs/platforms/python/feature-flags/index.mdx index 13b10a38359ba..3877517130fb9 100644 --- a/docs/platforms/python/feature-flags/index.mdx +++ b/docs/platforms/python/feature-flags/index.mdx @@ -16,5 +16,7 @@ Evaluation tracking requires enabling an SDK integration. Integrations are provi - [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/) - [LaunchDarkly](/platforms/python/integrations/feature-flags/launchdarkly/) +- [Unleash](/platforms/python/integrations/feature-flags/unleash/) +- [Generic](/platforms/python/integrations/feature-flags/generic/) diff --git a/docs/platforms/python/integrations/feature-flags/generic.mdx b/docs/platforms/python/integrations/feature-flags/generic.mdx new file mode 100644 index 0000000000000..458d88fe1af00 --- /dev/null +++ b/docs/platforms/python/integrations/feature-flags/generic.mdx @@ -0,0 +1,49 @@ +--- +title: Generic +description: "Learn how to attach custom feature flag data to Sentry error events." +--- + + + +The Feature Flags integration allows you to manually track feature flag evaluations through an API. These evaluations are held in memory, and in the event an error occurs, sent to Sentry for review and analysis. Specifically, the generic integration enables users to integrate with proprietary (or otherwise unsupported) feature flagging solutions. **At the moment, we only support boolean flag evaluations.** + +## Install + +Install `sentry-sdk` from PyPI. + +```bash +pip install --upgrade 'sentry-sdk' +``` + +## Configure + +Add `FeatureFlagsIntegration()` to your `integrations` list: + +```python +import sentry_sdk +from sentry_sdk.integrations.feature_flags import FeatureFlagsIntegration + +sentry_sdk.init( + dsn="___PUBLIC_DSN___", + integrations=[ + FeatureFlagsIntegration(), + ], +) +``` + +## Verify + +The integration is tested by calling the `add_feature_flag` API before capturing an exception. + +```python +import sentry_sdk +from sentry_sdk.integrations.feature_flags import add_feature_flag + +add_feature_flag('test-flag', False) + +sentry_sdk.capture_exception(Exception("Something went wrong!")) +``` + +Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false". + + diff --git a/docs/platforms/python/integrations/feature-flags/unleash.mdx b/docs/platforms/python/integrations/feature-flags/unleash.mdx new file mode 100644 index 0000000000000..04c4d25d11f11 --- /dev/null +++ b/docs/platforms/python/integrations/feature-flags/unleash.mdx @@ -0,0 +1,62 @@ +--- +title: Unleash +description: "Learn how to use Sentry with Unleash." +--- + + + +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`. + + From 76c4010c4514d6f27502c47431aef5ad6b79808d Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:24:03 -0800 Subject: [PATCH 2/5] Update unleash pkg version and sample code --- .../python/integrations/feature-flags/unleash.mdx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/platforms/python/integrations/feature-flags/unleash.mdx b/docs/platforms/python/integrations/feature-flags/unleash.mdx index 04c4d25d11f11..219d3e62662a5 100644 --- a/docs/platforms/python/integrations/feature-flags/unleash.mdx +++ b/docs/platforms/python/integrations/feature-flags/unleash.mdx @@ -9,7 +9,7 @@ The [Unleash](https://www.getunleash.io/) integration tracks feature flag evalua ## Install -Install `sentry-sdk` (>=2.19.3) and `UnleashClient` (>=6.0.1) from PyPI. +Install `sentry-sdk` (>=2.20.0) and `UnleashClient` (>=6.0.1) from PyPI. ```bash pip install --upgrade sentry-sdk UnleashClient @@ -39,9 +39,10 @@ Test the integration by evaluating a feature flag using your Unleash SDK before import sentry_sdk from UnleashClient import UnleashClient -unleash_client = UnleashClient(...) # See Unleash quickstart. -test_flag_enabled = unleash_client.is_enabled("test-flag") +unleash = UnleashClient(...) # See Unleash quickstart. +unleash.initialize_client() +test_flag_enabled = unleash.is_enabled("test-flag") sentry_sdk.capture_exception(Exception("Something went wrong!")) ``` @@ -49,10 +50,11 @@ sentry_sdk.capture_exception(Exception("Something went wrong!")) 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"] +unleash = UnleashClient(...) # See Unleash quickstart. +unleash.initialize_client() +test_flag_variant = unleash.get_variant("test-flag") +test_flag_enabled = test_flag_variant["enabled"] sentry_sdk.capture_exception(Exception("Something went wrong!")) ``` From c89ec773173e8b28e25040aa196b95a8e02a8ab9 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:02:45 -0800 Subject: [PATCH 3/5] Move python generic doc from integrations to index page section --- .../feature-flag/generic/index.mdx | 2 +- .../javascript/common/feature-flags/index.mdx | 5 +- docs/platforms/python/feature-flags/index.mdx | 23 +++++++-- .../integrations/feature-flags/generic.mdx | 49 ------------------- 4 files changed, 24 insertions(+), 55 deletions(-) delete mode 100644 docs/platforms/python/integrations/feature-flags/generic.mdx diff --git a/docs/organization/integrations/feature-flag/generic/index.mdx b/docs/organization/integrations/feature-flag/generic/index.mdx index bcf29e58d504b..11a05ea86fcac 100644 --- a/docs/organization/integrations/feature-flag/generic/index.mdx +++ b/docs/organization/integrations/feature-flag/generic/index.mdx @@ -14,7 +14,7 @@ To set up evaluation tracking, visit the [explore page](/product/explore/feature To set up generic evaluation tracking, visit one of our supported languages' pages: * [JavaScript](/platforms/javascript/configuration/integrations/generic/) -* [Python](/platforms/python/integrations/feature-flags/generic/) +* [Python](/platforms/python/feature-flags/#generic-api) ## Change Tracking diff --git a/docs/platforms/javascript/common/feature-flags/index.mdx b/docs/platforms/javascript/common/feature-flags/index.mdx index bcb0599d8503f..5f91083b9ea91 100644 --- a/docs/platforms/javascript/common/feature-flags/index.mdx +++ b/docs/platforms/javascript/common/feature-flags/index.mdx @@ -31,8 +31,9 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your ## Enable Evaluation Tracking Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below. -- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/) -- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/) + - [Generic](/platforms/javascript/configuration/integrations/generic/) +- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/) +- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/) diff --git a/docs/platforms/python/feature-flags/index.mdx b/docs/platforms/python/feature-flags/index.mdx index 3877517130fb9..95fde7deb2b5c 100644 --- a/docs/platforms/python/feature-flags/index.mdx +++ b/docs/platforms/python/feature-flags/index.mdx @@ -12,11 +12,28 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your ## Enable Evaluation Tracking -Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below. +Evaluation tracking typically requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below. -- [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/) +- [Generic (API)](/platforms/python/feature-flags/#generic-api) - [LaunchDarkly](/platforms/python/integrations/feature-flags/launchdarkly/) +- [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/) - [Unleash](/platforms/python/integrations/feature-flags/unleash/) -- [Generic](/platforms/python/integrations/feature-flags/generic/) + +### Generic API +The generic API allows you to manually track feature flag evaluations. These +evaluations are held in memory, and in the event an error occurs, sent to +Sentry for review and analysis. Specifically, the generic integration enables +users to integrate with proprietary (or otherwise unsupported) feature flagging +solutions. **At the moment, we only support boolean flag evaluations.** + +```python +from sentry_sdk.integrations.feature_flags import add_feature_flag + +add_feature_flag('test-flag', False) # Records an evaluation and its result. + +sentry_sdk.capture_exception(Exception("Something went wrong!")) +``` + +Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false". diff --git a/docs/platforms/python/integrations/feature-flags/generic.mdx b/docs/platforms/python/integrations/feature-flags/generic.mdx deleted file mode 100644 index 458d88fe1af00..0000000000000 --- a/docs/platforms/python/integrations/feature-flags/generic.mdx +++ /dev/null @@ -1,49 +0,0 @@ ---- -title: Generic -description: "Learn how to attach custom feature flag data to Sentry error events." ---- - - - -The Feature Flags integration allows you to manually track feature flag evaluations through an API. These evaluations are held in memory, and in the event an error occurs, sent to Sentry for review and analysis. Specifically, the generic integration enables users to integrate with proprietary (or otherwise unsupported) feature flagging solutions. **At the moment, we only support boolean flag evaluations.** - -## Install - -Install `sentry-sdk` from PyPI. - -```bash -pip install --upgrade 'sentry-sdk' -``` - -## Configure - -Add `FeatureFlagsIntegration()` to your `integrations` list: - -```python -import sentry_sdk -from sentry_sdk.integrations.feature_flags import FeatureFlagsIntegration - -sentry_sdk.init( - dsn="___PUBLIC_DSN___", - integrations=[ - FeatureFlagsIntegration(), - ], -) -``` - -## Verify - -The integration is tested by calling the `add_feature_flag` API before capturing an exception. - -```python -import sentry_sdk -from sentry_sdk.integrations.feature_flags import add_feature_flag - -add_feature_flag('test-flag', False) - -sentry_sdk.capture_exception(Exception("Something went wrong!")) -``` - -Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false". - - From c3a3ba0f911465a642d4895a7945f4895a476a1c Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 14 Jan 2025 09:53:22 +0100 Subject: [PATCH 4/5] small code snippet fix --- docs/platforms/python/feature-flags/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/python/feature-flags/index.mdx b/docs/platforms/python/feature-flags/index.mdx index 95fde7deb2b5c..1db7dd75a48b2 100644 --- a/docs/platforms/python/feature-flags/index.mdx +++ b/docs/platforms/python/feature-flags/index.mdx @@ -27,7 +27,7 @@ users to integrate with proprietary (or otherwise unsupported) feature flagging solutions. **At the moment, we only support boolean flag evaluations.** ```python -from sentry_sdk.integrations.feature_flags import add_feature_flag +from sentry_sdk.feature_flags import add_feature_flag add_feature_flag('test-flag', False) # Records an evaluation and its result. From c8ae4029cbe277a8f8b87caf0e789ff720eddf63 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 14 Jan 2025 10:08:12 +0100 Subject: [PATCH 5/5] Made feature flag docs consistent with other integrations --- docs/platforms/python/feature-flags/index.mdx | 11 +++++++---- .../python/integrations/feature-flags/index.mdx | 8 -------- .../launchdarkly.mdx => launchdarkly/index.mdx} | 0 .../openfeature.mdx => openfeature/index.mdx} | 0 .../{feature-flags/unleash.mdx => unleash/index.mdx} | 0 src/middleware.ts | 12 ++++++++++++ 6 files changed, 19 insertions(+), 12 deletions(-) delete mode 100644 docs/platforms/python/integrations/feature-flags/index.mdx rename docs/platforms/python/integrations/{feature-flags/launchdarkly.mdx => launchdarkly/index.mdx} (100%) rename docs/platforms/python/integrations/{feature-flags/openfeature.mdx => openfeature/index.mdx} (100%) rename docs/platforms/python/integrations/{feature-flags/unleash.mdx => unleash/index.mdx} (100%) diff --git a/docs/platforms/python/feature-flags/index.mdx b/docs/platforms/python/feature-flags/index.mdx index 1db7dd75a48b2..de5b5126d10d1 100644 --- a/docs/platforms/python/feature-flags/index.mdx +++ b/docs/platforms/python/feature-flags/index.mdx @@ -1,11 +1,14 @@ --- title: Set Up Feature Flags sidebar_order: 7000 -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. +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. --- +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. + + ## Prerequisites * You have the Python SDK installed. @@ -15,9 +18,9 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your Evaluation tracking typically requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below. - [Generic (API)](/platforms/python/feature-flags/#generic-api) -- [LaunchDarkly](/platforms/python/integrations/feature-flags/launchdarkly/) -- [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/) -- [Unleash](/platforms/python/integrations/feature-flags/unleash/) +- [LaunchDarkly](/platforms/python/integrations/launchdarkly/) +- [OpenFeature](/platforms/python/integrations/openfeature/) +- [Unleash](/platforms/python/integrations/unleash/) ### Generic API The generic API allows you to manually track feature flag evaluations. These diff --git a/docs/platforms/python/integrations/feature-flags/index.mdx b/docs/platforms/python/integrations/feature-flags/index.mdx deleted file mode 100644 index b5018499ae0e0..0000000000000 --- a/docs/platforms/python/integrations/feature-flags/index.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Feature Flags -description: "Learn about using Feature Flags with Sentry." ---- - -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. - -Sentry has added support for a variety of providers. Click through the nested sidebar listings to learn more. diff --git a/docs/platforms/python/integrations/feature-flags/launchdarkly.mdx b/docs/platforms/python/integrations/launchdarkly/index.mdx similarity index 100% rename from docs/platforms/python/integrations/feature-flags/launchdarkly.mdx rename to docs/platforms/python/integrations/launchdarkly/index.mdx diff --git a/docs/platforms/python/integrations/feature-flags/openfeature.mdx b/docs/platforms/python/integrations/openfeature/index.mdx similarity index 100% rename from docs/platforms/python/integrations/feature-flags/openfeature.mdx rename to docs/platforms/python/integrations/openfeature/index.mdx diff --git a/docs/platforms/python/integrations/feature-flags/unleash.mdx b/docs/platforms/python/integrations/unleash/index.mdx similarity index 100% rename from docs/platforms/python/integrations/feature-flags/unleash.mdx rename to docs/platforms/python/integrations/unleash/index.mdx diff --git a/src/middleware.ts b/src/middleware.ts index 7deefdd8ac336..03a1274b38517 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -505,6 +505,18 @@ const USER_DOCS_REDIRECTS: Redirect[] = [ from: '/platforms/python/tryton/', to: '/platforms/python/integrations/tryton/', }, + { + from: '/platforms/python/integrations/feature-flags/launchdarkly/', + to: '/platforms/python/integrations/launchdarkly/', + }, + { + from: '/platforms/python/integrations/feature-flags/openfeature/', + to: '/platforms/python/integrations/openfeature/', + }, + { + from: '/platforms/python/integrations/feature-flags/unleash/', + to: '/platforms/python/integrations/unleash/', + }, { from: '/clients/python/breadcrumbs/', to: '/platforms/python/legacy-sdk/breadcrumbs/',