From bb0f657e79605a3f0d2558239a6af78f800c8e79 Mon Sep 17 00:00:00 2001 From: Vjeran Grozdanic Date: Mon, 7 Apr 2025 16:45:24 +0200 Subject: [PATCH 1/3] docs(options): Promote usage of in_random_rollout --- develop-docs/backend/application-domains/options.mdx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/develop-docs/backend/application-domains/options.mdx b/develop-docs/backend/application-domains/options.mdx index e94bf86f759e89..21ec970736ad99 100644 --- a/develop-docs/backend/application-domains/options.mdx +++ b/develop-docs/backend/application-domains/options.mdx @@ -69,15 +69,13 @@ If you expect to frequently update your option, you can make it editable in the If you're working on a system-wide feature, you may choose to use options for your rollout instead of feature flags. Unlike feature flags, options don't allow for easy segmentation, but they are performant, stable, and simple to implement. e.g., ```python -import random -from sentry import options +from sentry.options.rollout import in_random_rollout -rate = options.get("performance.some-feature-rate") -if rate > random.random(): +if in_random_rollout("performance.some-feature-rate"): do_feature_stuff() ``` -However, be careful! Using `random.random` will cause your feature to be enabled and disabled randomly between page requests. This may be unacceptable for user-facing features. To avoid this, you can use the `sample_modulo` helper. e.g., +However, be careful! Using `in_random_rollout` uses `random.random` under the hood, and will cause your feature to be enabled and disabled randomly between page requests. This may be unacceptable for user-facing features. To avoid this, you can use the `sample_modulo` helper. e.g., ```python from sentry.utils.options import sample_modulo From be4de4e33b5dc290194458193f3a5f288d34a57d Mon Sep 17 00:00:00 2001 From: Vjeran Grozdanic Date: Mon, 7 Apr 2025 16:47:48 +0200 Subject: [PATCH 2/3] better text --- .../backend/application-domains/options.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/develop-docs/backend/application-domains/options.mdx b/develop-docs/backend/application-domains/options.mdx index 21ec970736ad99..42c356f660c0c3 100644 --- a/develop-docs/backend/application-domains/options.mdx +++ b/develop-docs/backend/application-domains/options.mdx @@ -23,8 +23,8 @@ Follow these rules when adding new options: The value of an option can be any pickleable value. - It is safe to declare and use an option in the same pull request, you don't need to - split them up. + It is safe to declare and use an option in the same pull request, you don't + need to split them up. ## Using Options @@ -56,8 +56,8 @@ options.set("performance.some-feature-rate", 0.01) ``` - If you do not have access to the shell, you'll need to contact OPS to set the option - value for you. + If you do not have access to the shell, you'll need to contact OPS to set the + option value for you. ### Options UI @@ -75,7 +75,7 @@ if in_random_rollout("performance.some-feature-rate"): do_feature_stuff() ``` -However, be careful! Using `in_random_rollout` uses `random.random` under the hood, and will cause your feature to be enabled and disabled randomly between page requests. This may be unacceptable for user-facing features. To avoid this, you can use the `sample_modulo` helper. e.g., +However, be careful! `in_random_rollout` uses `random.random` under the hood, and will cause your feature to be enabled and disabled randomly between page requests. This may be unacceptable for user-facing features. To avoid this, you can use the `sample_modulo` helper. e.g., ```python from sentry.utils.options import sample_modulo @@ -124,6 +124,6 @@ options.delete("performance.some-feature-rate") ``` - If you do not have access to the shell, you'll need to contact OPS to remove the option - for you. + If you do not have access to the shell, you'll need to contact OPS to remove + the option for you. From 6bdf7e7a45b53dd70778ad64e448d52867da545b Mon Sep 17 00:00:00 2001 From: Vjeran Grozdanic Date: Mon, 7 Apr 2025 16:50:36 +0200 Subject: [PATCH 3/3] revert formatting --- develop-docs/backend/application-domains/options.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/develop-docs/backend/application-domains/options.mdx b/develop-docs/backend/application-domains/options.mdx index 6da6cd8b5f8d09..441265edd99ef9 100644 --- a/develop-docs/backend/application-domains/options.mdx +++ b/develop-docs/backend/application-domains/options.mdx @@ -23,8 +23,8 @@ Follow these rules when adding new options: The value of an option can be any pickleable value. - It is safe to declare and use an option in the same pull request, you don't - need to split them up. + It is safe to declare and use an option in the same pull request, you don't need to + split them up. ## Using Options @@ -56,8 +56,8 @@ options.set("performance.some-feature-rate", 0.01) ``` - If you do not have access to the shell, you'll need to contact OPS to set the - option value for you. + If you do not have access to the shell, you'll need to contact OPS to set the option + value for you. ### Options UI @@ -124,6 +124,6 @@ options.delete("performance.some-feature-rate") ``` - If you do not have access to the shell, you'll need to contact OPS to remove - the option for you. + If you do not have access to the shell, you'll need to contact OPS to remove the option + for you.