Extend Insights to support the query option
Release notes
This issue is a breakdown from a spike issue which makes the DORA metrics exposable via the Insights feature.
High-level Steps
- Introduce an extra library layer for supporting the new YAML schema and delegating to the correct backend (finder).
- Adjust the Insights parameter validation rules to accommodate the new schema changes.
- Update the documentation with examples.
Details
To make this work, we can introduce an extra layer (maybe a lib?) which is responsible for the YAML options processing and delegation to the correct backend (finder). This is currently implemented as a mixin on the controller-level: InsightsActions
After this change, the controller would look much cleaner, something like this:
def query
Gitlab::Insights::Validators::ParamsValidator.new(params).validate!
render json: Serializer.new(Insights::Loader.new(chart_params).call)
end
The Loader is responsible for the following:
- Handle/transform the incoming parameters in a backwards-compatible manner (old Insights files should still work.
- Delegate to the correct Finder class and return the data to the serializer.
Configuration
Old configuration (it should work with the new changes):
bugsCharts:
title: "Charts for bugs"
charts:
- title: "Monthly bugs created"
description: "Open bugs created per month"
type: bar
query:
issuable_type: issue
issuable_state: opened
group_by: month
period_limit: 12
New configuration (with 2 charts, Issuable finder based and DORA base):
bugsCharts:
title: "Charts for bugs"
charts:
- title: "Monthly bugs created"
description: "Open bugs created per month"
type: bar
query:
data_source: issuable
params:
issuable_type: issue
issuable_state: opened
group_by: month
period_limit: 12
- title: "DORA DF"
description: "Deployment frequency"
type: bar
query:
data_source: dora
params:
metric: deployment_frequency
environment_tiers:
- production
period_limit: 12
Note: the DORA finder might not support all the possible chart times or period options.
Edited by Haim Snir