Skip to content

Commit a6f6557

Browse files
authored
docs(options): Promote usage of in_random_rollout (#13265)
* docs(options): Promote usage of in_random_rollout * better text * revert formatting
1 parent 4e81f52 commit a6f6557

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

develop-docs/backend/application-domains/options.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,13 @@ If you expect to frequently update your option, you can make it editable in the
6969
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.,
7070

7171
```python
72-
import random
73-
from sentry import options
72+
from sentry.options.rollout import in_random_rollout
7473

75-
rate = options.get("performance.some-feature-rate")
76-
if rate > random.random():
74+
if in_random_rollout("performance.some-feature-rate"):
7775
do_feature_stuff()
7876
```
7977

80-
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.,
78+
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.,
8179

8280
```python
8381
from sentry.utils.options import sample_modulo

0 commit comments

Comments
 (0)