Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
0e093940
Commit
0e093940
authored
Apr 25, 2019
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move dashboard param to initialize method
parent
8926b37d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
20 deletions
+19
-20
lib/gitlab/metrics/dashboard/processor.rb
lib/gitlab/metrics/dashboard/processor.rb
+5
-4
lib/gitlab/metrics/dashboard/service.rb
lib/gitlab/metrics/dashboard/service.rb
+1
-1
lib/gitlab/metrics/dashboard/stages/base_stage.rb
lib/gitlab/metrics/dashboard/stages/base_stage.rb
+4
-6
lib/gitlab/metrics/dashboard/stages/common_metrics_inserter.rb
...itlab/metrics/dashboard/stages/common_metrics_inserter.rb
+1
-1
lib/gitlab/metrics/dashboard/stages/project_metrics_inserter.rb
...tlab/metrics/dashboard/stages/project_metrics_inserter.rb
+1
-1
lib/gitlab/metrics/dashboard/stages/sorter.rb
lib/gitlab/metrics/dashboard/stages/sorter.rb
+5
-5
spec/lib/gitlab/metrics/dashboard/processor_spec.rb
spec/lib/gitlab/metrics/dashboard/processor_spec.rb
+2
-2
No files found.
lib/gitlab/metrics/dashboard/processor.rb
View file @
0e093940
...
@@ -14,17 +14,18 @@ module Gitlab
...
@@ -14,17 +14,18 @@ module Gitlab
Stages
::
Sorter
Stages
::
Sorter
].
freeze
].
freeze
def
initialize
(
project
,
environment
)
def
initialize
(
project
,
environment
,
dashboard
)
@project
=
project
@project
=
project
@environment
=
environment
@environment
=
environment
@dashboard
=
dashboard
end
end
# Returns a new dashboard hash with the results of
# Returns a new dashboard hash with the results of
# running transforms on the dashboard.
# running transforms on the dashboard.
def
process
(
raw_dashboard
)
def
process
raw_
dashboard
.
deep_symbolize_keys
.
tap
do
|
dashboard
|
@
dashboard
.
deep_symbolize_keys
.
tap
do
|
dashboard
|
sequence
.
each
do
|
stage
|
sequence
.
each
do
|
stage
|
stage
.
new
(
@project
,
@environment
).
transform!
(
dashboard
)
stage
.
new
(
@project
,
@environment
,
dashboard
).
transform!
end
end
end
end
end
end
...
...
lib/gitlab/metrics/dashboard/service.rb
View file @
0e093940
...
@@ -32,7 +32,7 @@ module Gitlab
...
@@ -32,7 +32,7 @@ module Gitlab
# Returns a new dashboard Hash, supplemented with DB info
# Returns a new dashboard Hash, supplemented with DB info
def
process_dashboard
(
dashboard
)
def
process_dashboard
(
dashboard
)
Gitlab
::
Metrics
::
Dashboard
::
Processor
.
new
(
project
,
params
[
:environment
]
).
process
(
dashboard
)
Gitlab
::
Metrics
::
Dashboard
::
Processor
.
new
(
project
,
params
[
:environment
]
,
dashboard
).
process
end
end
end
end
end
end
...
...
lib/gitlab/metrics/dashboard/stages/base_stage.rb
View file @
0e093940
...
@@ -9,18 +9,16 @@ module Gitlab
...
@@ -9,18 +9,16 @@ module Gitlab
DEFAULT_PANEL_TYPE
=
'area-chart'
DEFAULT_PANEL_TYPE
=
'area-chart'
attr_reader
:project
,
:environment
attr_reader
:project
,
:environment
,
:dashboard
def
initialize
(
project
,
environment
)
def
initialize
(
project
,
environment
,
dashboard
)
@project
=
project
@project
=
project
@environment
=
environment
@environment
=
environment
@dashboard
=
dashboard
end
end
# Entry-point to the stage
# Entry-point to the stage
# @param dashboard [Hash]
def
transform!
# @param project [Project]
# @param environment [Environment]
def
transform!
(
_dashboard
)
raise
NotImplementedError
raise
NotImplementedError
end
end
...
...
lib/gitlab/metrics/dashboard/stages/common_metrics_inserter.rb
View file @
0e093940
...
@@ -8,7 +8,7 @@ module Gitlab
...
@@ -8,7 +8,7 @@ module Gitlab
# For each metric in the dashboard config, attempts to
# For each metric in the dashboard config, attempts to
# find a corresponding database record. If found,
# find a corresponding database record. If found,
# includes the record's id in the dashboard config.
# includes the record's id in the dashboard config.
def
transform!
(
dashboard
)
def
transform!
common_metrics
=
::
PrometheusMetric
.
common
common_metrics
=
::
PrometheusMetric
.
common
for_metrics
(
dashboard
)
do
|
metric
|
for_metrics
(
dashboard
)
do
|
metric
|
...
...
lib/gitlab/metrics/dashboard/stages/project_metrics_inserter.rb
View file @
0e093940
...
@@ -8,7 +8,7 @@ module Gitlab
...
@@ -8,7 +8,7 @@ module Gitlab
# Inserts project-specific metrics into the dashboard
# Inserts project-specific metrics into the dashboard
# config. If there are no project-specific metrics,
# config. If there are no project-specific metrics,
# this will have no effect.
# this will have no effect.
def
transform!
(
dashboard
)
def
transform!
project
.
prometheus_metrics
.
each
do
|
project_metric
|
project
.
prometheus_metrics
.
each
do
|
project_metric
|
group
=
find_or_create_panel_group
(
dashboard
[
:panel_groups
],
project_metric
)
group
=
find_or_create_panel_group
(
dashboard
[
:panel_groups
],
project_metric
)
panel
=
find_or_create_panel
(
group
[
:panels
],
project_metric
)
panel
=
find_or_create_panel
(
group
[
:panels
],
project_metric
)
...
...
lib/gitlab/metrics/dashboard/stages/sorter.rb
View file @
0e093940
...
@@ -5,22 +5,22 @@ module Gitlab
...
@@ -5,22 +5,22 @@ module Gitlab
module
Dashboard
module
Dashboard
module
Stages
module
Stages
class
Sorter
<
BaseStage
class
Sorter
<
BaseStage
def
transform!
(
dashboard
)
def
transform!
missing_panel_groups!
unless
dashboard
[
:panel_groups
].
is_a?
Array
missing_panel_groups!
unless
dashboard
[
:panel_groups
].
is_a?
Array
sort_groups!
(
dashboard
)
sort_groups!
sort_panels!
(
dashboard
)
sort_panels!
end
end
private
private
# Sorts the groups in the dashboard by the :priority key
# Sorts the groups in the dashboard by the :priority key
def
sort_groups!
(
dashboard
)
def
sort_groups!
dashboard
[
:panel_groups
]
=
dashboard
[
:panel_groups
].
sort_by
{
|
group
|
-
group
[
:priority
].
to_i
}
dashboard
[
:panel_groups
]
=
dashboard
[
:panel_groups
].
sort_by
{
|
group
|
-
group
[
:priority
].
to_i
}
end
end
# Sorts the panels in the dashboard by the :weight key
# Sorts the panels in the dashboard by the :weight key
def
sort_panels!
(
dashboard
)
def
sort_panels!
dashboard
[
:panel_groups
].
each
do
|
group
|
dashboard
[
:panel_groups
].
each
do
|
group
|
missing_panels!
unless
group
[
:panels
].
is_a?
Array
missing_panels!
unless
group
[
:panels
].
is_a?
Array
...
...
spec/lib/gitlab/metrics/dashboard/processor_spec.rb
View file @
0e093940
...
@@ -8,8 +8,8 @@ describe Gitlab::Metrics::Dashboard::Processor do
...
@@ -8,8 +8,8 @@ describe Gitlab::Metrics::Dashboard::Processor do
let
(
:dashboard_yml
)
{
YAML
.
load_file
(
'spec/fixtures/lib/gitlab/metrics/dashboard/sample_dashboard.yml'
)
}
let
(
:dashboard_yml
)
{
YAML
.
load_file
(
'spec/fixtures/lib/gitlab/metrics/dashboard/sample_dashboard.yml'
)
}
describe
'process'
do
describe
'process'
do
let
(
:process_params
)
{
[
project
,
environment
]
}
let
(
:process_params
)
{
[
project
,
environment
,
dashboard_yml
]
}
let
(
:dashboard
)
{
described_class
.
new
(
*
process_params
).
process
(
dashboard_yml
)
}
let
(
:dashboard
)
{
described_class
.
new
(
*
process_params
).
process
}
context
'when dashboard config corresponds to common metrics'
do
context
'when dashboard config corresponds to common metrics'
do
let!
(
:common_metric
)
{
create
(
:prometheus_metric
,
:common
,
identifier:
'metric_a1'
)
}
let!
(
:common_metric
)
{
create
(
:prometheus_metric
,
:common
,
identifier:
'metric_a1'
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment