diff options
author | Eileen Uchitelle <eileencodes@gmail.com> | 2018-10-09 14:08:25 -0400 |
---|---|---|
committer | Eileen Uchitelle <eileencodes@gmail.com> | 2018-10-10 08:07:12 -0400 |
commit | e8c1be4ae7797f3ede588d2cf04a0155b4d6ce4a (patch) | |
tree | 99a96136ddf8581c53da3ce08f3b88660eaa92f8 /actionpack | |
parent | 168a9728dd00069efe04fec4b59d29e3752fbfb3 (diff) | |
download | rails-e8c1be4ae7797f3ede588d2cf04a0155b4d6ce4a.tar.gz rails-e8c1be4ae7797f3ede588d2cf04a0155b4d6ce4a.tar.bz2 rails-e8c1be4ae7797f3ede588d2cf04a0155b4d6ce4a.zip |
Add allocations to template renderer subscription
This PR adds the allocations to the instrumentation for template and
partial rendering.
Before:
```
Rendering posts/new.html.erb within layouts/application
Rendered posts/_form.html.erb (9.7ms)
Rendered posts/new.html.erb within layouts/application (10.9ms)
Completed 200 OK in 902ms (Views: 890.8ms | ActiveRecord: 0.8ms)
```
After:
```
Rendering posts/new.html.erb within layouts/application
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)
```
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/log_subscriber.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/log_subscriber.rb b/actionpack/lib/action_controller/log_subscriber.rb index 6de1fb2c19..afbd38e7fe 100644 --- a/actionpack/lib/action_controller/log_subscriber.rb +++ b/actionpack/lib/action_controller/log_subscriber.rb @@ -18,14 +18,17 @@ module ActionController 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? |