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
7f8a6e6a
Commit
7f8a6e6a
authored
Feb 02, 2021
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement reviewer feedback
Implement reviewer feedback
parent
420f42b0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
14 deletions
+28
-14
app/controllers/projects/ci/prometheus_metrics/histograms_controller.rb
...s/projects/ci/prometheus_metrics/histograms_controller.rb
+1
-1
app/services/ci/prometheus_metrics/observe_histograms_service.rb
...vices/ci/prometheus_metrics/observe_histograms_service.rb
+3
-5
doc/administration/monitoring/prometheus/gitlab_metrics.md
doc/administration/monitoring/prometheus/gitlab_metrics.md
+1
-1
spec/requests/projects/ci/promeheus_metrics/histograms_controller_spec.rb
...ojects/ci/promeheus_metrics/histograms_controller_spec.rb
+14
-0
spec/services/ci/prometheus_metrics/observe_histograms_service_spec.rb
.../ci/prometheus_metrics/observe_histograms_service_spec.rb
+9
-7
No files found.
app/controllers/projects/ci/prometheus_metrics/histograms_controller.rb
View file @
7f8a6e6a
...
...
@@ -11,7 +11,7 @@ module Projects
def
create
result
=
::
Ci
::
PrometheusMetrics
::
ObserveHistogramsService
.
new
(
project
,
permitted_params
).
execute
render
json:
result
.
body
,
status:
result
.
status
render
json:
result
.
payload
,
status:
result
.
http_
status
end
private
...
...
app/services/ci/prometheus_metrics/observe_histograms_service.rb
View file @
7f8a6e6a
...
...
@@ -3,14 +3,12 @@
module
Ci
module
PrometheusMetrics
class
ObserveHistogramsService
Result
=
Struct
.
new
(
:status
,
:body
,
keyword_init:
true
)
class
<<
self
def
available_histograms
@available_histograms
||=
[
histogram
(
:pipeline_graph_link_calculation_duration_seconds
,
'Total time spent calculating links, in seconds'
,
{},
[
0.05
,
0.1
,
0.2
,
0.3
,
0.4
,
0.5
,
0.8
,
1
,
2
]),
histogram
(
:pipeline_graph_links_total
,
'Number of links per graph'
,
{},
[
1
,
5
,
10
,
25
,
50
,
100
,
200
]),
histogram
(
:pipeline_graph_link_per_job_ratio
,
'Ratio of links to job per graph'
,
{},
[
0.1
,
0.2
,
0.3
,
0.4
,
0.5
,
0.6
,
0.7
,
0.8
,
0.9
,
1
])
histogram
(
:pipeline_graph_link
s
_per_job_ratio
,
'Ratio of links to job per graph'
,
{},
[
0.1
,
0.2
,
0.3
,
0.4
,
0.5
,
0.6
,
0.7
,
0.8
,
0.9
,
1
])
].
to_h
end
...
...
@@ -27,13 +25,13 @@ module Ci
end
def
execute
return
Result
.
new
(
status:
202
,
body:
{}
)
unless
enabled?
return
ServiceResponse
.
success
(
http_status: :accepted
)
unless
enabled?
params
.
fetch
(
:histograms
,
[])
.
each
(
&
method
(
:observe
))
Result
.
new
(
status:
201
,
body:
{}
)
ServiceResponse
.
success
(
http_status: :created
)
end
private
...
...
doc/administration/monitoring/prometheus/gitlab_metrics.md
View file @
7f8a6e6a
...
...
@@ -121,7 +121,7 @@ The following metrics are available:
|
`ci_report_parser_duration_seconds`
| Histogram | 13.9 | Time to parse CI/CD report artifacts |
`parser`
|
|
`pipeline_graph_link_calculation_duration_seconds`
| Histogram | 13.9 | Total time spent calculating links, in seconds |
`project`
|
|
`pipeline_graph_links_total`
| Histogram | 13.9 | Number of links per graph |
`project`
|
|
`pipeline_graph_link
_per_job_ratio`
| Histogram | 13.9 | Ratio of links to job per graph |
`project`
|
|
`pipeline_graph_link
s_per_job_ratio`
| Histogram | 13.9 | Ratio of links to job per graph |
`project`
|
## Metrics controlled by a feature flag
...
...
spec/requests/projects/ci/promeheus_metrics/histograms_controller_spec.rb
View file @
7f8a6e6a
...
...
@@ -24,6 +24,20 @@ RSpec.describe 'Projects::Ci::PrometheusMetrics::HistogramsController' do
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'with the feature flag disabled'
do
before
do
stub_feature_flags
(
ci_accept_frontend_prometheus_metrics:
false
)
end
it
'returns 202 Accepted'
do
post
histograms_route
(
histograms:
[
{
name: :pipeline_graph_link_calculation_duration_seconds
,
value:
1
}
])
expect
(
response
).
to
have_gitlab_http_status
(
:accepted
)
end
end
end
def
histograms_route
(
params
=
{})
...
...
spec/services/ci/prometheus_metrics/observe_histograms_service_spec.rb
View file @
7f8a6e6a
...
...
@@ -14,7 +14,7 @@ RSpec.describe Ci::PrometheusMetrics::ObserveHistogramsService do
context
'with empty data'
do
it
'does not raise errors'
do
expect
(
subject
.
status
).
to
eq
(
201
)
is_expected
.
to
be_success
end
end
...
...
@@ -23,7 +23,7 @@ RSpec.describe Ci::PrometheusMetrics::ObserveHistogramsService do
{
histograms:
[
{
name:
'pipeline_graph_link_calculation_duration_seconds'
,
value:
'1'
},
{
name:
'pipeline_graph_link_per_job_ratio'
,
value:
'0.9'
}
{
name:
'pipeline_graph_link
s
_per_job_ratio'
,
value:
'0.9'
}
]
}
end
...
...
@@ -33,13 +33,14 @@ RSpec.describe Ci::PrometheusMetrics::ObserveHistogramsService do
expect
(
histogram_data
).
to
match
(
a_hash_including
({
0.8
=>
0.0
,
1
=>
1.0
,
2
=>
1.0
}))
expect
(
histogram_data
(
:pipeline_graph_link_per_job_ratio
))
expect
(
histogram_data
(
:pipeline_graph_link
s
_per_job_ratio
))
.
to
match
(
a_hash_including
({
0.8
=>
0.0
,
0.9
=>
1.0
,
1
=>
1.0
}))
end
it
'returns an empty body and status code'
do
expect
(
subject
.
status
).
to
eq
(
201
)
expect
(
subject
.
body
).
to
eq
({})
is_expected
.
to
be_success
expect
(
subject
.
http_status
).
to
eq
(
:created
)
expect
(
subject
.
payload
).
to
eq
({})
end
end
...
...
@@ -73,8 +74,9 @@ RSpec.describe Ci::PrometheusMetrics::ObserveHistogramsService do
end
it
'returns an empty body and status code'
do
expect
(
subject
.
status
).
to
eq
(
202
)
expect
(
subject
.
body
).
to
eq
({})
is_expected
.
to
be_success
expect
(
subject
.
http_status
).
to
eq
(
:accepted
)
expect
(
subject
.
payload
).
to
eq
({})
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