DORA + Insights: handle dates with missing data
What does this MR do and why?
DORA + Insights: handle missing data points (#371885 - closed) ensures that dates with no data available will return a null
value for the DORA insights charts, previously the data was simply skipped from the response.
This MR adds support for the null
series in insights charts, ensuring we render a dotted line for periods of the chart that do not have data available. This also helps better differentiate between dates that have a value of 0
vs dates that have no data, bringing the insights charts closer to the look of the CI/CD charts.
Screenshots or screen recordings
Dora charts
Before | After |
---|---|
Non Dora charts (issuables)
Before | After |
---|---|
How to set up and validate locally
Configure insights for DORA
- Ensure that you're on ultimate.
- Create a new group with 3 projects: "project1, project2, insights_config"
- Configure the insights config location for the group:
General settings > Insights
(insights_config
) - For project1 and project2, create an environment called
production
: Deployments > Environments - Edit the
insights_config
project with web IDE and add a config file:.gitlab/insights.yml
using this config:
.gitlab/insights.yml config file
dora:
title: "DORA charts"
charts:
- title: "DORA deployment frequency"
description: "DORA deployment frequency"
type: line
query:
data_source: dora
params:
metric: deployment_frequency
group_by: day
period_limit: 3
projects:
only:
- dora-insights/insights_config
- dora-insights/project1
- dora-insights/project2
- title: "DORA lead time for changes"
description: "DORA lead time for changes"
type: line
query:
data_source: dora
params:
metric: lead_time_for_changes
group_by: day
environment_tiers:
- staging
period_limit: 45
- title: "DORA time to restore service"
description: "DORA time to restore service"
type: line
query:
data_source: dora
params:
metric: time_to_restore_service
group_by: day
period_limit: 45
- title: "DORA change failure rate"
description: "DORA change failure rate"
type: line
query:
data_source: dora
params:
metric: change_failure_rate
group_by: day
period_limit: 45
Test data
- Apply this patch for test data
Mock insights data
diff --git a/ee/app/assets/javascripts/insights/stores/modules/insights/mutations.js b/ee/app/assets/javascripts/insights/stores/modules/insights/mutations.js
index 1cc846cea11a..f4b539cbfadd 100644
--- a/ee/app/assets/javascripts/insights/stores/modules/insights/mutations.js
+++ b/ee/app/assets/javascripts/insights/stores/modules/insights/mutations.js
@@ -1,5 +1,6 @@
import { pick } from 'lodash';
+import { timeToRestore, leadTime, changeFailureRate, deploymentFrequency } from '../mock_data';
import { transformChartDataForGlCharts } from './helpers';
import * as types from './mutation_types';
@@ -23,6 +24,19 @@ export default {
[types.RECEIVE_CHART_SUCCESS](state, { chart, data }) {
const { type, description } = chart;
+ if (chart.query.params.metric === 'lead_time_for_changes') {
+ data = leadTime;
+ }
+ if (chart.query.params.metric === 'time_to_restore_service') {
+ data = timeToRestore;
+ }
+ if (chart.query.params.metric === 'change_failure_rate') {
+ data = changeFailureRate;
+ }
+ if (chart.query.params.metric === 'deployment_frequency') {
+ data = deploymentFrequency;
+ }
+
state.chartData[chart.title] = {
type,
description,
diff --git a/ee/app/assets/javascripts/insights/stores/modules/mock_data.js b/ee/app/assets/javascripts/insights/stores/modules/mock_data.js
new file mode 100644
index 000000000000..2a6c19aa4ae7
--- /dev/null
+++ b/ee/app/assets/javascripts/insights/stores/modules/mock_data.js
@@ -0,0 +1,196 @@
+const labels = [
+ '01 Sep 22',
+ '02 Sep 22',
+ '03 Sep 22',
+ '04 Sep 22',
+ '05 Sep 22',
+ '06 Sep 22',
+ '07 Sep 22',
+ '08 Sep 22',
+ '09 Sep 22',
+ '10 Sep 22',
+ '11 Sep 22',
+ '12 Sep 22',
+ '13 Sep 22',
+ '14 Sep 22',
+ '15 Sep 22',
+ '16 Sep 22',
+ '17 Sep 22',
+ '18 Sep 22',
+ '19 Sep 22',
+ '20 Sep 22',
+ '21 Sep 22',
+ '22 Sep 22',
+ '23 Sep 22',
+ '24 Sep 22',
+ '25 Sep 22',
+ '26 Sep 22',
+ '27 Sep 22',
+ '28 Sep 22',
+ '29 Sep 22',
+ '30 Sep 22',
+];
+
+export const deploymentFrequency = {
+ labels,
+ datasets: [
+ {
+ label: null,
+ data: [
+ 100,
+ 22,
+ null,
+ 45,
+ 78,
+ null,
+ 11,
+ 23,
+ null,
+ null,
+ null,
+ 14,
+ 0,
+ null,
+ 84,
+ 100,
+ 0,
+ 15,
+ null,
+ 100,
+ null,
+ null,
+ 74,
+ 100,
+ null,
+ 10,
+ 100,
+ 0,
+ 16,
+ 53,
+ ],
+ },
+ ],
+};
+
+export const changeFailureRate = {
+ labels,
+ datasets: [
+ {
+ label: null,
+ data: [
+ 0.0,
+ 0.0,
+ null,
+ 0.0,
+ 0.0,
+ null,
+ 0.0,
+ 0.0,
+ null,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.44,
+ null,
+ 0.25,
+ 0.0,
+ 0.123,
+ 0.24,
+ 0.5,
+ 0.0,
+ null,
+ null,
+ 0.0,
+ 0.0,
+ null,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ ],
+ },
+ ],
+};
+
+export const timeToRestore = {
+ labels,
+ datasets: [
+ {
+ label: null,
+ data: [
+ null,
+ null,
+ null,
+ 2.78,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 0.1,
+ null,
+ null,
+ 0.5,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 550.0,
+ null,
+ null,
+ null,
+ null,
+ ],
+ },
+ ],
+};
+
+export const leadTime = {
+ labels,
+ datasets: [
+ {
+ label: null,
+ data: [
+ 0.1,
+ 0.1,
+ 0.56,
+ 0.4,
+ 0,
+ 0.2,
+ 0.1,
+ null,
+ 0.1,
+ 2.5,
+ 0.3,
+ 0.1,
+ 0.1,
+ null,
+ null,
+ 0.24,
+ 0.0,
+ 0.1,
+ null,
+ 0.5,
+ null,
+ null,
+ 0.0,
+ null,
+ 0.3,
+ 0.4,
+ 0.6,
+ null,
+ null,
+ 2.1,
+ ],
+ },
+ ],
+};
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.
Related to #372136 (closed)
Edited by Ezekiel Kigbo