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
5c2844cd
Commit
5c2844cd
authored
Mar 07, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Align implementation after merge
parent
3c822c7a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
4 deletions
+15
-4
app/models/concerns/prometheus_adapter.rb
app/models/concerns/prometheus_adapter.rb
+7
-1
ee/lib/gitlab/prometheus/queries/validate_query.rb
ee/lib/gitlab/prometheus/queries/validate_query.rb
+5
-0
ee/spec/controllers/projects/prometheus/metrics_controller_spec.rb
...ontrollers/projects/prometheus/metrics_controller_spec.rb
+3
-3
No files found.
app/models/concerns/prometheus_adapter.rb
View file @
5c2844cd
...
@@ -26,7 +26,13 @@ module PrometheusAdapter
...
@@ -26,7 +26,13 @@ module PrometheusAdapter
query_class
=
Gitlab
::
Prometheus
::
Queries
.
const_get
(
"
#{
query_name
.
to_s
.
classify
}
Query"
)
query_class
=
Gitlab
::
Prometheus
::
Queries
.
const_get
(
"
#{
query_name
.
to_s
.
classify
}
Query"
)
args
.
map!
(
&
:id
)
args
.
map!
do
|
arg
|
if
arg
.
respond_to?
(
:id
)
arg
.
id
else
arg
end
end
with_reactive_cache
(
query_class
.
name
,
*
args
,
&
query_class
.
method
(
:transform_reactive_result
))
with_reactive_cache
(
query_class
.
name
,
*
args
,
&
query_class
.
method
(
:transform_reactive_result
))
end
end
...
...
ee/lib/gitlab/prometheus/queries/validate_query.rb
View file @
5c2844cd
...
@@ -8,6 +8,11 @@ module Gitlab
...
@@ -8,6 +8,11 @@ module Gitlab
rescue
Gitlab
::
PrometheusClient
::
QueryError
=>
ex
rescue
Gitlab
::
PrometheusClient
::
QueryError
=>
ex
{
valid:
false
,
error:
ex
.
message
}
{
valid:
false
,
error:
ex
.
message
}
end
end
def
self
.
transform_reactive_result
(
result
)
result
[
:query
]
=
result
.
delete
:data
result
end
end
end
end
end
end
end
...
...
ee/spec/controllers/projects/prometheus/metrics_controller_spec.rb
View file @
5c2844cd
...
@@ -4,11 +4,11 @@ describe Projects::Prometheus::MetricsController do
...
@@ -4,11 +4,11 @@ describe Projects::Prometheus::MetricsController do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:prometheus_project
)
}
let
(
:project
)
{
create
(
:prometheus_project
)
}
let
(
:prometheus_
service
)
{
project
.
prometheus_service
}
let
(
:prometheus_
adapter
)
{
double
(
'prometheus_adapter'
,
can_query?:
true
)
}
before
do
before
do
allow
(
controller
).
to
receive
(
:project
).
and_return
(
project
)
allow
(
controller
).
to
receive
(
:project
).
and_return
(
project
)
allow
(
controller
).
to
receive
(
:prometheus_
service
).
and_return
(
prometheus_service
)
allow
(
controller
).
to
receive
(
:prometheus_
adapter
).
and_return
(
prometheus_adapter
)
project
.
add_master
(
user
)
project
.
add_master
(
user
)
sign_in
(
user
)
sign_in
(
user
)
...
@@ -16,7 +16,7 @@ describe Projects::Prometheus::MetricsController do
...
@@ -16,7 +16,7 @@ describe Projects::Prometheus::MetricsController do
describe
'POST #validate_query'
do
describe
'POST #validate_query'
do
before
do
before
do
allow
(
prometheus_
service
).
to
receive
(
:query
).
with
(
:validate
,
query
)
{
validation_result
}
allow
(
prometheus_
adapter
).
to
receive
(
:query
).
with
(
:validate
,
query
)
{
validation_result
}
end
end
let
(
:query
)
{
'avg(metric)'
}
let
(
:query
)
{
'avg(metric)'
}
...
...
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