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
Boxiang Sun
gitlab-ce
Commits
6eb96b20
Commit
6eb96b20
authored
Jun 07, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `key?` instead of `has_key?`
parent
dbb3c280
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
lib/gitlab/prometheus/additional_metrics_parser.rb
lib/gitlab/prometheus/additional_metrics_parser.rb
+2
-2
lib/gitlab/prometheus/queries/query_additional_metrics.rb
lib/gitlab/prometheus/queries/query_additional_metrics.rb
+1
-1
No files found.
lib/gitlab/prometheus/additional_metrics_parser.rb
View file @
6eb96b20
...
@@ -14,14 +14,14 @@ module Gitlab
...
@@ -14,14 +14,14 @@ module Gitlab
end
end
def
metric_from_entry
(
entry
)
def
metric_from_entry
(
entry
)
missing_fields
=
[
:title
,
:required_metrics
,
:weight
,
:queries
].
select
{
|
key
|
!
entry
.
has_
key?
(
key
)
}
missing_fields
=
[
:title
,
:required_metrics
,
:weight
,
:queries
].
select
{
|
key
|
!
entry
.
key?
(
key
)
}
raise
ParsingError
.
new
(
"entry missing required fields
#{
missing_fields
}
"
)
unless
missing_fields
.
empty?
raise
ParsingError
.
new
(
"entry missing required fields
#{
missing_fields
}
"
)
unless
missing_fields
.
empty?
Metric
.
new
(
entry
[
:title
],
entry
[
:required_metrics
],
entry
[
:weight
],
entry
[
:y_label
],
entry
[
:queries
])
Metric
.
new
(
entry
[
:title
],
entry
[
:required_metrics
],
entry
[
:weight
],
entry
[
:y_label
],
entry
[
:queries
])
end
end
def
group_from_entry
(
entry
)
def
group_from_entry
(
entry
)
missing_fields
=
[
:group
,
:priority
,
:metrics
].
select
{
|
key
|
!
entry
.
has_
key?
(
key
)
}
missing_fields
=
[
:group
,
:priority
,
:metrics
].
select
{
|
key
|
!
entry
.
key?
(
key
)
}
raise
ParsingError
.
new
(
"entry missing required fields
#{
missing_fields
}
"
)
unless
missing_fields
.
empty?
raise
ParsingError
.
new
(
"entry missing required fields
#{
missing_fields
}
"
)
unless
missing_fields
.
empty?
group
=
MetricGroup
.
new
(
entry
[
:group
],
entry
[
:priority
])
group
=
MetricGroup
.
new
(
entry
[
:group
],
entry
[
:priority
])
...
...
lib/gitlab/prometheus/queries/query_additional_metrics.rb
View file @
6eb96b20
...
@@ -44,7 +44,7 @@ module Gitlab
...
@@ -44,7 +44,7 @@ module Gitlab
def
process_query
(
context
,
query
)
def
process_query
(
context
,
query
)
query_with_result
=
query
.
dup
query_with_result
=
query
.
dup
query_with_result
[
:result
]
=
query_with_result
[
:result
]
=
if
query
.
has_
key?
(
:query_range
)
if
query
.
key?
(
:query_range
)
client_query_range
(
query
[
:query_range
]
%
context
,
start:
context
[
:timeframe_start
],
stop:
context
[
:timeframe_end
])
client_query_range
(
query
[
:query_range
]
%
context
,
start:
context
[
:timeframe_start
],
stop:
context
[
:timeframe_end
])
else
else
client_query
(
query
[
:query
]
%
context
,
time:
context
[
:timeframe_end
])
client_query
(
query
[
:query
]
%
context
,
time:
context
[
:timeframe_end
])
...
...
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