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
13902e40
Commit
13902e40
authored
Jun 16, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memoize only yaml loading method
parent
8b69523b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
7 deletions
+2
-7
lib/gitlab/prometheus/additional_metrics_parser.rb
lib/gitlab/prometheus/additional_metrics_parser.rb
+2
-2
spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
+0
-5
No files found.
lib/gitlab/prometheus/additional_metrics_parser.rb
View file @
13902e40
...
...
@@ -23,11 +23,11 @@ module Gitlab
end
def
additional_metrics_raw
@additional_metrics_raw
||=
load_yaml_file
&
.
map
(
&
:deep_symbolize_keys
).
freeze
load_yaml_file
&
.
map
(
&
:deep_symbolize_keys
).
freeze
end
def
load_yaml_file
YAML
.
load_file
(
Rails
.
root
.
join
(
'config/prometheus/additional_metrics.yml'
))
@loaded_yaml_file
||=
YAML
.
load_file
(
Rails
.
root
.
join
(
'config/prometheus/additional_metrics.yml'
))
end
end
end
...
...
spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
View file @
13902e40
...
...
@@ -33,7 +33,6 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
before
do
described_class
.
instance_variable_set
:@additional_metrics_raw
,
nil
allow
(
described_class
).
to
receive
(
:load_yaml_file
)
{
YAML
.
load
(
sample_yaml
)
}
end
...
...
@@ -68,10 +67,6 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
shared_examples
'required field'
do
|
field_name
|
before
do
described_class
.
instance_variable_set
:@additional_metrics_raw
,
nil
end
context
"when
#{
field_name
}
is nil"
do
before
do
allow
(
described_class
).
to
receive
(
:load_yaml_file
)
{
YAML
.
load
(
field_missing
)
}
...
...
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