From 2f1b54f63abd4d241c9a0b4a254da654ae511991 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:29:52 -0800 Subject: [PATCH 1/4] feat(flags): document python FeatureFlagsIntegration for custom flag tracking --- .../integrations/feature_flags/index.mdx | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 docs/platforms/python/integrations/feature_flags/index.mdx diff --git a/docs/platforms/python/integrations/feature_flags/index.mdx b/docs/platforms/python/integrations/feature_flags/index.mdx new file mode 100644 index 0000000000000..b8b0aa54877bb --- /dev/null +++ b/docs/platforms/python/integrations/feature_flags/index.mdx @@ -0,0 +1,50 @@ +--- +title: Feature Flags +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. +**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('hello', False) + +sentry_sdk.capture_exception(Exception("Something went wrong!")) +``` + +Visit the Sentry website and confirm that your error event has recorded the feature flag "hello" and its value "false". + + From 426d3219ded236752e8e9bfde6653e19a6b3d8c2 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:33:53 -0800 Subject: [PATCH 2/4] rm underscore in feature_flags to keep consistent w python sdk --- .../integrations/{feature_flags => featureflags}/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename docs/platforms/python/integrations/{feature_flags => featureflags}/index.mdx (89%) diff --git a/docs/platforms/python/integrations/feature_flags/index.mdx b/docs/platforms/python/integrations/featureflags/index.mdx similarity index 89% rename from docs/platforms/python/integrations/feature_flags/index.mdx rename to docs/platforms/python/integrations/featureflags/index.mdx index b8b0aa54877bb..e5327a11c6c0a 100644 --- a/docs/platforms/python/integrations/feature_flags/index.mdx +++ b/docs/platforms/python/integrations/featureflags/index.mdx @@ -22,7 +22,7 @@ Add `FeatureFlagsIntegration()` to your `integrations` list: ```python import sentry_sdk -from sentry_sdk.integrations.feature_flags import FeatureFlagsIntegration +from sentry_sdk.integrations.featureflags import FeatureFlagsIntegration sentry_sdk.init( dsn="___PUBLIC_DSN___", @@ -38,7 +38,7 @@ The integration is tested by calling the `add_feature_flag` API before capturing ```python import sentry_sdk -from sentry_sdk.integrations.feature_flags import add_feature_flag +from sentry_sdk.integrations.featureflags import add_feature_flag add_feature_flag('hello', False) From d7c9ef2b8c6bb7a86bb83d9fd72b26f16f115595 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:12:31 -0800 Subject: [PATCH 3/4] Rename test flag --- docs/platforms/python/integrations/featureflags/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/platforms/python/integrations/featureflags/index.mdx b/docs/platforms/python/integrations/featureflags/index.mdx index e5327a11c6c0a..4b0fdfa5133b0 100644 --- a/docs/platforms/python/integrations/featureflags/index.mdx +++ b/docs/platforms/python/integrations/featureflags/index.mdx @@ -40,11 +40,11 @@ The integration is tested by calling the `add_feature_flag` API before capturing import sentry_sdk from sentry_sdk.integrations.featureflags import add_feature_flag -add_feature_flag('hello', False) +add_feature_flag('test-flag', False) sentry_sdk.capture_exception(Exception("Something went wrong!")) ``` -Visit the Sentry website and confirm that your error event has recorded the feature flag "hello" and its value "false". +Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag" and its value "false". From c43046dd17d5f3ee93d930b86be703a1131b47d1 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:25:42 -0800 Subject: [PATCH 4/4] Link in python index --- docs/platforms/python/feature-flags/index.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/platforms/python/feature-flags/index.mdx b/docs/platforms/python/feature-flags/index.mdx index 75b471db24967..0f674e343955a 100644 --- a/docs/platforms/python/feature-flags/index.mdx +++ b/docs/platforms/python/feature-flags/index.mdx @@ -16,5 +16,6 @@ Evaluation tracking requires enabling an SDK integration. Integrations are provi - [OpenFeature](/platforms/python/integrations/openfeature/) - [LaunchDarkly](/platforms/python/integrations/launchdarkly/) +- [Manual Tracking](/platforms/python/integrations/featureflags/) - if you use an unsupported or in-house provider, you may track evaluations through an API.