Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
a5079f68
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a5079f68
编写于
8月 22, 2016
作者:
P
Paco Guzman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adds response mime type to transaction metric action when it's not HTML
上级
a03da79f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
6 deletion
+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
未找到文件。
CHANGELOG
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录