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
ca4a2642
Commit
ca4a2642
authored
Sep 27, 2019
by
Ryan Cobb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for http_request_duration_seconds
parent
3ac1d9ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
lib/gitlab/metrics/requests_rack_middleware.rb
lib/gitlab/metrics/requests_rack_middleware.rb
+3
-3
spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
+14
-0
No files found.
lib/gitlab/metrics/requests_rack_middleware.rb
View file @
ca4a2642
...
...
@@ -3,7 +3,7 @@
module
Gitlab
module
Metrics
class
RequestsRackMiddleware
METHODS
=
%w(delete get head options patch post put trace)
.
freeze
HTTP_
METHODS
=
%w(delete get head options patch post put trace)
.
freeze
STATUSES
=
%w(200 301 304 400 401 403 404 500)
.
freeze
def
initialize
(
app
)
...
...
@@ -24,9 +24,9 @@ module Gitlab
end
def
self
.
initialize_http_request_duration_seconds
METHODS
.
each
do
|
method
|
HTTP_
METHODS
.
each
do
|
method
|
STATUSES
.
each
do
|
status
|
::
Gitlab
::
Metrics
.
histogram
(
:http_request_duration_seconds
,
'Request handling execution time'
)
.
get
({
method:
method
,
status:
status
})
http_request_duration_seconds
.
get
({
method:
method
,
status:
status
})
end
end
end
...
...
spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
View file @
ca4a2642
...
...
@@ -63,5 +63,19 @@ describe Gitlab::Metrics::RequestsRackMiddleware do
expect
{
subject
.
call
(
env
)
}.
to
raise_error
(
StandardError
)
end
end
describe
'.initialize_http_request_duration_seconds'
do
it
"sets labels"
do
expected_labels
=
[]
described_class
::
HTTP_METHODS
.
each
do
|
method
|
described_class
::
STATUSES
.
each
do
|
status
|
expected_labels
<<
{
method:
method
,
status:
status
}
end
end
described_class
.
initialize_http_request_duration_seconds
expect
(
described_class
.
http_request_duration_seconds
.
values
.
keys
).
to
include
(
*
expected_labels
)
end
end
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