Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #10446 from dasch/instrument-template-compilation

Instrument template compilation
  • Loading branch information...
commit b8577bb67356fead9b72fe36766e32495aa56f52 2 parents 17c1143 + d6b9e8e
Rafael Mendonça França rafaelfranca authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 actionpack/lib/action_view/template.rb
11 actionpack/lib/action_view/template.rb
View
@@ -138,7 +138,7 @@ def supports_streaming?
# we use a bang in this instrumentation because you don't want to
# consume this in production. This is only slow if it's being listened to.
def render(view, locals, buffer=nil, &block)
- ActiveSupport::Notifications.instrument("!render_template.action_view", virtual_path: @virtual_path, identifier: @identifier) do
+ instrument("!render_template") do
compile!(view)
view.send(method_name, locals, buffer, &block)
end
@@ -245,7 +245,9 @@ def compile!(view) #:nodoc:
mod = view.singleton_class
end
- compile(view, mod)
+ instrument("!compile_template") do
+ compile(view, mod)
+ end
# Just discard the source if we have a virtual path. This
# means we can get the template back.
@@ -335,5 +337,10 @@ def method_name #:nodoc:
def identifier_method_name #:nodoc:
inspect.gsub(/[^a-z_]/, '_')
end
+
+ def instrument(action, &block)
+ payload = { virtual_path: @virtual_path, identifier: @identifier }
+ ActiveSupport::Notifications.instrument("#{action}.action_view", payload, &block)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.