578.md 4.0 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
# Experiment Guide

> 原文:[https://docs.gitlab.com/ee/development/experiment_guide/](https://docs.gitlab.com/ee/development/experiment_guide/)

*   [Experiment tracking issue](#experiment-tracking-issue)
*   [Code reviews](#code-reviews)
*   [How to create an A/B test](#how-to-create-an-ab-test)

# Experiment Guide[](#experiment-guide "Permalink")

任何 GitLab 小组都可以进行实验,大多数情况下是来自[成长子部门的小组](https://about.gitlab.com/handbook/engineering/development/growth/) . 实验与发布无关,因为它们主要针对 GitLab.com.

实验将作为 A / B 测试运行,并且位于功能标记后面以打开或关闭测试. 根据实验产生的数据,团队将决定实验是否产生了积极影响,并将其设置为新的默认值或回滚.

## Experiment tracking issue[](#experiment-tracking-issue "Permalink")

每个实验都应有一个[实验跟踪](https://gitlab.com/groups/gitlab-org/-/issues?scope=all&utf8=✓&state=opened&label_name[]=growth experiment&search=)问题,以跟踪从推出到清除/删除的实验. 部署实验后,应立即设置问题的到期日期(这取决于实验,但最多可能需要几周的时间). 在截止日期之后,该问题需要解决,并且可以:

*   成功,实验将成为新的默认设置.
*   它不成功,与实验相关的所有代码都将被删除.

无论哪种情况,都应将实验结果与决策依据一起发布到问题上.

## Code reviews[](#code-reviews "Permalink")

由于实验代码在很长一段时间内都不会成为代码库的一部分,并且我们想快速迭代以检索数据,因此实验的代码质量有时可能无法满足我们的标准,但无论实验是否为 GitLab 都不会对其产生负面影响运行与否. 最初,实验仅会部署到一小部分用户,但我们仍希望为这些用户提供完美的体验. 因此,实验仍然需要测试.

对于审阅者和维护者:如果您发现通常无法通过审阅但暂时可以接受的代码,请提及您的疑虑,但请注意,无需进行更改. 然后,作者在这段代码中添加注释,并添加指向该问题的链接以解决该实验. 如果实验成功并成为产品的一部分,则应解决这些后续问题.

## How to create an A/B test[](#how-to-create-an-ab-test "Permalink")

*   实验添加到`Gitlab::Experimentation::EXPERIMENTS`中的散列[`experimentation.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/experimentation.rb)

    ```
    EXPERIMENTS = {
      other_experiment: {
        #...
      },
      # Add your experiment here:
      signup_flow: {
        environment: ::Gitlab.dev_env_or_com?, # Target environment, defaults to enabled for development and GitLab.com
        tracking_category: 'Growth::Acquisition::Experiment::SignUpFlow' # Used for providing the category when setting up tracking data
      }
    }.freeze 
    ```

*   在控制器中使用实验:

    ```
    class RegistrationController < ApplicationController
     def show
       # experiment_enabled?(:feature_name) is also available in views and helpers
       if experiment_enabled?(:signup_flow)
         # render the experiment
       else
         # render the original version
       end
     end
    end 
    ```

*   跟踪必要的事件. 有关详细信息,请参见[遥测指南](../telemetry/index.html) .
*   合并请求合并后, [`chatops`](../../ci/chatops/README.html)[适当的通道中](../feature_flags/controls.html#communicate-the-change)使用[`chatops`](../../ci/chatops/README.html)来为 10%的用户启动实验. 功能标记应带有附加了`_experiment_percentage`后缀的实验名称. 为了提高可视性,请在`#s_growth`通道中共享对生产运行的所有命令:

    ```
    /chatops run feature set signup_flow_experiment_percentage 10 
    ```

    如果发现实验存在问题,则可以通过删除功能标记来禁用实验:

    ```
    /chatops run feature delete signup_flow_experiment_percentage 
    ```