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
66ff5cb0
Commit
66ff5cb0
authored
Jan 13, 2020
by
Kirstie Cook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backend for allowing sample metrics to be toggled from ui
parent
c618698c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
4 deletions
+22
-4
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+2
-2
config/routes/project.rb
config/routes/project.rb
+1
-1
lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb
lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb
+1
-1
spec/lib/gitlab/metrics/dashboard/processor_spec.rb
spec/lib/gitlab/metrics/dashboard/processor_spec.rb
+18
-0
No files found.
app/controllers/projects/environments_controller.rb
View file @
66ff5cb0
...
...
@@ -222,8 +222,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def
metrics_dashboard_params
params
.
permit
(
:embedded
,
:group
,
:title
,
:y_label
,
:dashboard_path
,
:environment
)
.
merge
(
dashboard_path:
params
[
:dashboard
],
environment:
environment
)
.
permit
(
:embedded
,
:group
,
:title
,
:y_label
,
:dashboard_path
,
:environment
,
:sample_metrics
)
.
merge
(
dashboard_path:
params
[
:dashboard
],
environment:
environment
,
sample_metrics:
params
[
:sample_metrics
]
)
end
def
include_all_dashboards?
...
...
config/routes/project.rb
View file @
66ff5cb0
...
...
@@ -242,7 +242,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get
'/prometheus/api/v1/*proxy_path'
,
to:
'environments/prometheus_api#proxy'
,
as: :prometheus_api
get
'/sample_metrics'
,
to:
'environments/sample_metrics#query'
if
ENV
[
'USE_SAMPLE_METRICS'
]
get
'/sample_metrics'
,
to:
'environments/sample_metrics#query'
end
collection
do
...
...
lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb
View file @
66ff5cb0
...
...
@@ -16,7 +16,7 @@ module Gitlab
private
def
endpoint_for_metric
(
metric
)
if
ENV
[
'USE_SAMPLE_METRICS'
]
if
params
[
:sample_metrics
]
Gitlab
::
Routing
.
url_helpers
.
sample_metrics_project_environment_path
(
project
,
params
[
:environment
],
...
...
spec/lib/gitlab/metrics/dashboard/processor_spec.rb
View file @
66ff5cb0
...
...
@@ -86,6 +86,16 @@ describe Gitlab::Metrics::Dashboard::Processor do
expect
(
metrics
).
to
eq
%w(metric_b metric_a2 metric_a1)
end
end
context
'when sample metrics are present'
do
let
(
:process_params
)
{
[
project
,
dashboard_yml
,
sequence
,
{
environment:
environment
,
sample_metrics:
true
}]
}
it
'includes a sample metrics path for the prometheus endpoint with each metric'
do
expect
(
all_metrics
).
to
satisfy_all
do
|
metric
|
metric
[
:prometheus_endpoint_path
]
==
sample_metrics_path
(
metric
[
:id
])
end
end
end
end
shared_examples_for
'errors with message'
do
|
expected_message
|
...
...
@@ -147,4 +157,12 @@ describe Gitlab::Metrics::Dashboard::Processor do
query:
query
)
end
def
sample_metrics_path
(
metric
)
Gitlab
::
Routing
.
url_helpers
.
sample_metrics_project_environment_path
(
project
,
environment
,
identifier:
metric
)
end
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