Commit 6b19d505 authored by Russell Dickenson's avatar Russell Dickenson

Merge branch 'add-paragraph-to-experiment-guide' into 'master'

Add use case for enabled_for_attribute? method in experiment guide

See merge request gitlab-org/gitlab!44165
parents 02370a8d 6456c6fa
......@@ -86,6 +86,25 @@ addressed.
}
```
- It is also possible to run an experiment outside of the controller scope, for example in a worker:
```ruby
class SomeWorker
def perform
# Check if the experiment is enabled at all (the percentage_of_time_value > 0)
return unless Gitlab::Experimentation.enabled?(:experiment_key)
# Since we cannot access cookies in a worker, we need to bucket models based on a unique, unchanging attribute instead.
# Use the following method to check if the experiment is enabled for a certain attribute, for example a username or email address:
if Gitlab::Experimentation.enabled_for_attribute?(:experiment_key, some_attribute)
# execute experimental code
else
# execute control code
end
end
end
```
1. Track necessary events. See the [telemetry guide](../telemetry/index.md) for details.
1. After the merge request is merged, use [`chatops`](../../ci/chatops/README.md) in the
[appropriate channel](../feature_flags/controls.md#communicate-the-change) to start the experiment for 10% of the users.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment