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
a5079f68
Commit
a5079f68
authored
Aug 22, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds response mime type to transaction metric action when it's not HTML
parent
a03da79f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
6 deletions
+38
-6
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab/metrics/rack_middleware.rb
lib/gitlab/metrics/rack_middleware.rb
+20
-2
spec/lib/gitlab/metrics/rack_middleware_spec.rb
spec/lib/gitlab/metrics/rack_middleware_spec.rb
+17
-4
No files found.
CHANGELOG
View file @
a5079f68
...
...
@@ -11,6 +11,7 @@ v 8.12.0 (unreleased)
- Added 'only_allow_merge_if_build_succeeds' project setting in the API. !5930 (Duck)
- Reduce number of database queries on builds tab
- Use the default branch for displaying the project icon instead of master !5792 (Hannes Rosenögger)
- Adds response mime type to transaction metric action when it's not HTML
v 8.11.2 (unreleased)
- Show "Create Merge Request" widget for push events to fork projects on the source project
...
...
lib/gitlab/metrics/rack_middleware.rb
View file @
a5079f68
...
...
@@ -4,6 +4,17 @@ module Gitlab
class
RackMiddleware
CONTROLLER_KEY
=
'action_controller.instance'
ENDPOINT_KEY
=
'api.endpoint'
CONTENT_TYPES
=
{
'text/html'
=>
:html
,
'text/plain'
=>
:txt
,
'application/json'
=>
:json
,
'text/js'
=>
:js
,
'application/atom+xml'
=>
:atom
,
'image/png'
=>
:png
,
'image/jpeg'
=>
:jpeg
,
'image/gif'
=>
:gif
,
'image/svg+xml'
=>
:svg
}
def
initialize
(
app
)
@app
=
app
...
...
@@ -46,8 +57,15 @@ module Gitlab
end
def
tag_controller
(
trans
,
env
)
controller
=
env
[
CONTROLLER_KEY
]
trans
.
action
=
"
#{
controller
.
class
.
name
}
#
#{
controller
.
action_name
}
"
controller
=
env
[
CONTROLLER_KEY
]
action
=
"
#{
controller
.
class
.
name
}
#
#{
controller
.
action_name
}
"
suffix
=
CONTENT_TYPES
[
controller
.
content_type
]
if
suffix
&&
suffix
!=
:html
action
+=
".
#{
suffix
}
"
end
trans
.
action
=
action
end
def
tag_endpoint
(
trans
,
env
)
...
...
spec/lib/gitlab/metrics/rack_middleware_spec.rb
View file @
a5079f68
...
...
@@ -19,7 +19,7 @@ describe Gitlab::Metrics::RackMiddleware do
end
it
'tags a transaction with the name and action of a controller'
do
klass
=
double
(
:klass
,
name:
'TestController'
)
klass
=
double
(
:klass
,
name:
'TestController'
,
content_type:
'text/html'
)
controller
=
double
(
:controller
,
class:
klass
,
action_name:
'show'
)
env
[
'action_controller.instance'
]
=
controller
...
...
@@ -32,7 +32,7 @@ describe Gitlab::Metrics::RackMiddleware do
middleware
.
call
(
env
)
end
it
'tags a transaction with the method andpath of the route in the grape endpoint'
do
it
'tags a transaction with the method and
path of the route in the grape endpoint'
do
route
=
double
(
:route
,
route_method:
"GET"
,
route_path:
"/:version/projects/:id/archive(.:format)"
)
endpoint
=
double
(
:endpoint
,
route:
route
)
...
...
@@ -87,17 +87,30 @@ describe Gitlab::Metrics::RackMiddleware do
describe
'#tag_controller'
do
let
(
:transaction
)
{
middleware
.
transaction_from_env
(
env
)
}
let
(
:content_type
)
{
'text/html'
}
it
'tags a transaction with the name and action of a controller'
do
before
do
klass
=
double
(
:klass
,
name:
'TestController'
)
controller
=
double
(
:controller
,
class:
klass
,
action_name:
'show'
)
controller
=
double
(
:controller
,
class:
klass
,
action_name:
'show'
,
content_type:
content_type
)
env
[
'action_controller.instance'
]
=
controller
end
it
'tags a transaction with the name and action of a controller'
do
middleware
.
tag_controller
(
transaction
,
env
)
expect
(
transaction
.
action
).
to
eq
(
'TestController#show'
)
end
context
'when the response content type is not :html'
do
let
(
:content_type
)
{
'application/json'
}
it
'appends the mime type to the transaction action'
do
middleware
.
tag_controller
(
transaction
,
env
)
expect
(
transaction
.
action
).
to
eq
(
'TestController#show.json'
)
end
end
end
describe
'#tag_endpoint'
do
...
...
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