Introduce linear regression experiment on Deployment Frequency chart
Demo
Current gif demo of what's enabled for a few people on production as of 2023-04-14
What does this MR do and why?
Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/403630+
This MR introduces linear regression in Vanilla JS for frontend forecasting on charts. The first chart to receive this addition is the CI/CD Deployment Frequency chart.
The linear regression calculation is based off of https://oliverjumpertz.com/simple-linear-regression-theory-math-and-implementation-in-javascript/
Example of the linear regression output:
// Given the following dataset:
const timeSeriesData = [
{ date: '2023-01-12', value: 160 },
{ date: '2023-01-13', value: 52 },
{ date: '2023-01-14', value: 47 },
{ date: '2023-01-15', value: 37 },
{ date: '2023-01-16', value: 106 },
{ date: '2023-01-17', value: 178 },
{ date: '2023-01-18', value: 161 },
{ date: '2023-01-19', value: 173 },
{ date: '2023-01-20', value: 101 },
{ date: '2023-01-21', value: 31 },
];
// And calling
linearRegression(timeSeriesData, 7);
// The returned response will be
[
{ date: "2023-01-22", value: 113 },
{ date: "2023-01-23", value: 115 },
{ date: "2023-01-24", value: 116 },
{ date: "2023-01-25", value: 118 },
{ date: "2023-01-26", value: 119 },
{ date: "2023-01-27", value: 121 },
{ date: "2023-01-28", value: 122 }
];
The forecasting is displayed by clicking a toggle, at which point the data will then be computed and rendered to the chart to match the design in https://gitlab.com/gitlab-org/gitlab/-/issues/403630/designs/A_Deploymeny-frequency-forecast.png
TODO
-
Add linear regression logic -
Add toggle to the chart behind a group based feature flag -
Add alert flow for opt in -
Append the additional data to the chart when toggle is selected -
Change forecast date range based on selected date range -
Ensure tooltips and legend make sense - if applicable -
Potentially refactor the linear regression logic -
Make sure that everything is tested
Open questions
- What should the forecast ranges be foreach deployment frequency date range, i.e.
last week
,last month
, etc
This question has been clarified:
Last week = 7d + 3 forecast
Last month = 30d + 15 forecast
Last 90 days = 90d + 45 forecast
Last 180 days = 180d + 90 forecast
Screenshots or screen recordings
Width | Forecast | |
---|---|---|
Full | Off | |
Full | On | |
Mobile | Off | |
Mobile | On | |
Opt in | n/a |
How to set up and validate locally
Feature.enable(:dora_charts_forecast, GROUP_ID)
- Browse to http://{local-instance}/groups/gitlab-org/-/analytics/ci_cd?tab=deployment-frequency
- Click the toggle
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.