Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
8ecb75e4
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
8ecb75e4
编写于
10月 10, 2018
作者:
E
Eileen M. Uchitelle
提交者:
GitHub
10月 10, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #34136 from rails/add-allocations-to-template-renderer
Add allocations to template renderer subscription
上级
a52c6989
e8c1be4a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
12 deletion
+27
-12
actionpack/lib/action_controller/log_subscriber.rb
actionpack/lib/action_controller/log_subscriber.rb
+5
-2
actionview/CHANGELOG.md
actionview/CHANGELOG.md
+12
-0
actionview/lib/action_view/log_subscriber.rb
actionview/lib/action_view/log_subscriber.rb
+3
-3
actionview/test/activerecord/controller_runtime_test.rb
actionview/test/activerecord/controller_runtime_test.rb
+5
-5
actionview/test/template/log_subscriber_test.rb
actionview/test/template/log_subscriber_test.rb
+2
-2
未找到文件。
actionpack/lib/action_controller/log_subscriber.rb
浏览文件 @
8ecb75e4
...
...
@@ -18,14 +18,17 @@ def start_processing(event)
def
process_action
(
event
)
info
do
payload
=
event
.
payload
payload
=
event
.
payload
additions
=
ActionController
::
Base
.
log_process_action
(
payload
)
status
=
payload
[
:status
]
if
status
.
nil?
&&
payload
[
:exception
].
present?
exception_class_name
=
payload
[
:exception
].
first
status
=
ActionDispatch
::
ExceptionWrapper
.
status_code_for_exception
(
exception_class_name
)
end
additions
<<
"Allocations:
#{
event
.
allocations
}
"
message
=
+
"Completed
#{
status
}
#{
Rack
::
Utils
::
HTTP_STATUS_CODES
[
status
]
}
in
#{
event
.
duration
.
round
}
ms"
message
<<
" (
#{
additions
.
join
(
" | "
)
}
)"
unless
additions
.
empty?
message
<<
"
\n\n
"
if
defined?
(
Rails
.
env
)
&&
Rails
.
env
.
development?
...
...
actionview/CHANGELOG.md
浏览文件 @
8ecb75e4
*
Add allocations to template rendering instrumentation.
Adds the allocations for template and partial rendering to the server output on render.
```
Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004)
Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654)
Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564)
```
*Eileen M. Uchitelle*, *Aaron Patterson*
*
Respect the
`only_path`
option passed to
`url_for`
when the options are passed in as an array
Fixes #33237.
...
...
actionview/lib/action_view/log_subscriber.rb
浏览文件 @
8ecb75e4
...
...
@@ -18,7 +18,7 @@ def render_template(event)
info
do
message
=
+
" Rendered
#{
from_rails_root
(
event
.
payload
[
:identifier
])
}
"
message
<<
" within
#{
from_rails_root
(
event
.
payload
[
:layout
])
}
"
if
event
.
payload
[
:layout
]
message
<<
" (
#{
event
.
duration
.
round
(
1
)
}
ms
)"
message
<<
" (
Duration:
#{
event
.
duration
.
round
(
1
)
}
ms | Allocations:
#{
event
.
allocations
}
)"
end
end
...
...
@@ -26,7 +26,7 @@ def render_partial(event)
info
do
message
=
+
" Rendered
#{
from_rails_root
(
event
.
payload
[
:identifier
])
}
"
message
<<
" within
#{
from_rails_root
(
event
.
payload
[
:layout
])
}
"
if
event
.
payload
[
:layout
]
message
<<
" (
#{
event
.
duration
.
round
(
1
)
}
ms
)"
message
<<
" (
Duration:
#{
event
.
duration
.
round
(
1
)
}
ms | Allocations:
#{
event
.
allocations
}
)"
message
<<
"
#{
cache_message
(
event
.
payload
)
}
"
unless
event
.
payload
[
:cache_hit
].
nil?
message
end
...
...
@@ -37,7 +37,7 @@ def render_collection(event)
info
do
" Rendered collection of
#{
from_rails_root
(
identifier
)
}
"
\
"
#{
render_count
(
event
.
payload
)
}
(
#{
event
.
duration
.
round
(
1
)
}
ms
)"
"
#{
render_count
(
event
.
payload
)
}
(
Duration:
#{
event
.
duration
.
round
(
1
)
}
ms | Allocations:
#{
event
.
allocations
}
)"
end
end
...
...
actionview/test/activerecord/controller_runtime_test.rb
浏览文件 @
8ecb75e4
...
...
@@ -68,7 +68,7 @@ def test_log_with_active_record
wait
assert_equal
2
,
@logger
.
logged
(
:info
).
size
assert_match
(
/\(Views: [\d.]+ms \| ActiveRecord: [\d.]+ms\)/
,
@logger
.
logged
(
:info
)[
1
])
assert_match
(
/\(Views: [\d.]+ms \| ActiveRecord: [\d.]+ms
\| Allocations: [\d.]+
\)/
,
@logger
.
logged
(
:info
)[
1
])
end
def
test_runtime_reset_before_requests
...
...
@@ -77,20 +77,20 @@ def test_runtime_reset_before_requests
wait
assert_equal
2
,
@logger
.
logged
(
:info
).
size
assert_match
(
/\(Views: [\d.]+ms \| ActiveRecord:
0\.0ms
\)/
,
@logger
.
logged
(
:info
)[
1
])
assert_match
(
/\(Views: [\d.]+ms \| ActiveRecord:
[\d.]+ms \| Allocations: [\d.]+
\)/
,
@logger
.
logged
(
:info
)[
1
])
end
def
test_log_with_active_record_when_post
post
:create
wait
assert_match
(
/ActiveRecord: ([1-9][\d.]+)ms\)/
,
@logger
.
logged
(
:info
)[
2
])
assert_match
(
/ActiveRecord: ([1-9][\d.]+)ms
\| Allocations: [\d.]+
\)/
,
@logger
.
logged
(
:info
)[
2
])
end
def
test_log_with_active_record_when_redirecting
get
:redirect
wait
assert_equal
3
,
@logger
.
logged
(
:info
).
size
assert_match
(
/\(ActiveRecord: [\d.]+ms\)/
,
@logger
.
logged
(
:info
)[
2
])
assert_match
(
/\(ActiveRecord: [\d.]+ms
\| Allocations: [\d.]+
\)/
,
@logger
.
logged
(
:info
)[
2
])
end
def
test_include_time_query_time_after_rendering
...
...
@@ -98,6 +98,6 @@ def test_include_time_query_time_after_rendering
wait
assert_equal
2
,
@logger
.
logged
(
:info
).
size
assert_match
(
/\(Views: [\d.]+ms \| ActiveRecord: ([1-9][\d.]+)ms\)/
,
@logger
.
logged
(
:info
)[
1
])
assert_match
(
/\(Views: [\d.]+ms \| ActiveRecord: ([1-9][\d.]+)ms
\| Allocations: [\d.]+
\)/
,
@logger
.
logged
(
:info
)[
1
])
end
end
actionview/test/template/log_subscriber_test.rb
浏览文件 @
8ecb75e4
...
...
@@ -129,14 +129,14 @@ def test_render_uncached_outer_partial_with_inner_cached_partial_wont_mix_cache_
wait
*
,
cached_inner
,
uncached_outer
=
@logger
.
logged
(
:info
)
assert_match
(
/Rendered test\/_cached_customer\.erb (.*) \[cache miss\]/
,
cached_inner
)
assert_match
(
/Rendered test\/_nested_cached_customer\.erb \(
.*?ms
\)$/
,
uncached_outer
)
assert_match
(
/Rendered test\/_nested_cached_customer\.erb \(
Duration: .*?ms \| Allocations: .*?
\)$/
,
uncached_outer
)
# Second render hits the cache for the _cached_customer partial. Outer template's log shouldn't be affected.
@view
.
render
(
partial:
"test/nested_cached_customer"
,
locals:
{
cached_customer:
Customer
.
new
(
"Stan"
)
})
wait
*
,
cached_inner
,
uncached_outer
=
@logger
.
logged
(
:info
)
assert_match
(
/Rendered test\/_cached_customer\.erb (.*) \[cache hit\]/
,
cached_inner
)
assert_match
(
/Rendered test\/_nested_cached_customer\.erb \(
.*?ms
\)$/
,
uncached_outer
)
assert_match
(
/Rendered test\/_nested_cached_customer\.erb \(
Duration: .*?ms \| Allocations: .*?
\)$/
,
uncached_outer
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录