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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
82e4e2a9
Commit
82e4e2a9
authored
Apr 25, 2019
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move dashboard param to initialize method
parent
7bbc1dd8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
25 deletions
+23
-25
ee/lib/ee/gitlab/metrics/dashboard/stages/alerts_inserter.rb
ee/lib/ee/gitlab/metrics/dashboard/stages/alerts_inserter.rb
+1
-1
ee/spec/lib/ee/gitlab/metrics/dashboard/processor_spec.rb
ee/spec/lib/ee/gitlab/metrics/dashboard/processor_spec.rb
+3
-4
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.
ee/lib/ee/gitlab/metrics/dashboard/stages/alerts_inserter.rb
View file @
82e4e2a9
...
...
@@ -8,7 +8,7 @@ module EE
module
Dashboard
module
Stages
class
AlertsInserter
<
::
Gitlab
::
Metrics
::
Dashboard
::
Stages
::
BaseStage
def
transform!
(
dashboard
)
def
transform!
return
if
metrics_with_alerts
.
empty?
for_metrics
(
dashboard
)
do
|
metric
|
...
...
ee/spec/lib/ee/gitlab/metrics/dashboard/processor_spec.rb
View file @
82e4e2a9
...
...
@@ -6,11 +6,11 @@ describe Gitlab::Metrics::Dashboard::Processor do
let
(
:project
)
{
build
(
:project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let
(
:dashboard_yml
)
{
YAML
.
load_file
(
'spec/fixtures/lib/gitlab/metrics/dashboard/sample_dashboard.yml'
)
}
let
(
:params
)
{
[
project
,
environment
,
dashboard_yml
]
}
describe
'sequence'
do
let
(
:environment
)
{
build
(
:environment
)
}
let
(
:process_params
)
{
[
project
,
environment
]
}
let
(
:sequence
)
{
described_class
.
new
(
*
process_params
).
sequence
}
let
(
:sequence
)
{
described_class
.
new
(
*
params
).
sequence
}
it
'includes the alerts processing stage'
do
expect
(
sequence
.
length
).
to
eq
(
4
)
...
...
@@ -18,8 +18,7 @@ describe Gitlab::Metrics::Dashboard::Processor do
end
describe
'process'
do
let
(
:process_params
)
{
[
project
,
environment
]
}
let
(
:dashboard
)
{
described_class
.
new
(
*
process_params
).
process
(
dashboard_yml
)
}
let
(
:dashboard
)
{
described_class
.
new
(
*
params
).
process
}
context
'when the dashboard references persisted metrics with alerts'
do
let!
(
:alert
)
do
...
...
lib/gitlab/metrics/dashboard/processor.rb
View file @
82e4e2a9
...
...
@@ -14,17 +14,18 @@ module Gitlab
Stages
::
Sorter
].
freeze
def
initialize
(
project
,
environment
)
def
initialize
(
project
,
environment
,
dashboard
)
@project
=
project
@environment
=
environment
@dashboard
=
dashboard
end
# Returns a new dashboard hash with the results of
# running transforms on the dashboard.
def
process
(
raw_dashboard
)
raw_
dashboard
.
deep_symbolize_keys
.
tap
do
|
dashboard
|
def
process
@
dashboard
.
deep_symbolize_keys
.
tap
do
|
dashboard
|
sequence
.
each
do
|
stage
|
stage
.
new
(
@project
,
@environment
).
transform!
(
dashboard
)
stage
.
new
(
@project
,
@environment
,
dashboard
).
transform!
end
end
end
...
...
lib/gitlab/metrics/dashboard/service.rb
View file @
82e4e2a9
...
...
@@ -32,7 +32,7 @@ module Gitlab
# Returns a new dashboard Hash, supplemented with DB info
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
...
...
lib/gitlab/metrics/dashboard/stages/base_stage.rb
View file @
82e4e2a9
...
...
@@ -9,18 +9,16 @@ module Gitlab
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
@environment
=
environment
@dashboard
=
dashboard
end
# Entry-point to the stage
# @param dashboard [Hash]
# @param project [Project]
# @param environment [Environment]
def
transform!
(
_dashboard
)
def
transform!
raise
NotImplementedError
end
...
...
lib/gitlab/metrics/dashboard/stages/common_metrics_inserter.rb
View file @
82e4e2a9
...
...
@@ -8,7 +8,7 @@ module Gitlab
# For each metric in the dashboard config, attempts to
# find a corresponding database record. If found,
# includes the record's id in the dashboard config.
def
transform!
(
dashboard
)
def
transform!
common_metrics
=
::
PrometheusMetric
.
common
for_metrics
(
dashboard
)
do
|
metric
|
...
...
lib/gitlab/metrics/dashboard/stages/project_metrics_inserter.rb
View file @
82e4e2a9
...
...
@@ -8,7 +8,7 @@ module Gitlab
# Inserts project-specific metrics into the dashboard
# config. If there are no project-specific metrics,
# this will have no effect.
def
transform!
(
dashboard
)
def
transform!
project
.
prometheus_metrics
.
each
do
|
project_metric
|
group
=
find_or_create_panel_group
(
dashboard
[
:panel_groups
],
project_metric
)
panel
=
find_or_create_panel
(
group
[
:panels
],
project_metric
)
...
...
lib/gitlab/metrics/dashboard/stages/sorter.rb
View file @
82e4e2a9
...
...
@@ -5,22 +5,22 @@ module Gitlab
module
Dashboard
module
Stages
class
Sorter
<
BaseStage
def
transform!
(
dashboard
)
def
transform!
missing_panel_groups!
unless
dashboard
[
:panel_groups
].
is_a?
Array
sort_groups!
(
dashboard
)
sort_panels!
(
dashboard
)
sort_groups!
sort_panels!
end
private
# 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
}
end
# Sorts the panels in the dashboard by the :weight key
def
sort_panels!
(
dashboard
)
def
sort_panels!
dashboard
[
:panel_groups
].
each
do
|
group
|
missing_panels!
unless
group
[
:panels
].
is_a?
Array
...
...
spec/lib/gitlab/metrics/dashboard/processor_spec.rb
View file @
82e4e2a9
...
...
@@ -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'
)
}
describe
'process'
do
let
(
:process_params
)
{
[
project
,
environment
]
}
let
(
:dashboard
)
{
described_class
.
new
(
*
process_params
).
process
(
dashboard_yml
)
}
let
(
:process_params
)
{
[
project
,
environment
,
dashboard_yml
]
}
let
(
:dashboard
)
{
described_class
.
new
(
*
process_params
).
process
}
context
'when dashboard config corresponds to common metrics'
do
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