mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add controller and action name to the instrumentation payload
This commit is contained in:
parent
b231825f3e
commit
92fbbf67e3
3 changed files with 31 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
|||
* Instrument fragment cache metrics.
|
||||
|
||||
Adds `:controller`: and `:action` keys to the instrumentation payload
|
||||
for the `*_fragment.action_controller` notifications. This allows tracking
|
||||
e.g. the fragment cache hit rates for each controller action.
|
||||
|
||||
*Daniel Schierbeck*
|
||||
|
||||
* Properly treat the entire IPv6 User Local Address space as private for
|
||||
purposes of remote IP detection. Also handle uppercase private IPv6
|
||||
addresses.
|
||||
|
|
|
@ -90,7 +90,13 @@ module ActionController
|
|||
end
|
||||
|
||||
def instrument_fragment_cache(name, key) # :nodoc:
|
||||
ActiveSupport::Notifications.instrument("#{name}.action_controller", :key => key){ yield }
|
||||
payload = {
|
||||
:controller => controller_name,
|
||||
:action => action_name,
|
||||
:key => key
|
||||
}
|
||||
|
||||
ActiveSupport::Notifications.instrument("#{name}.action_controller", payload){ yield }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -227,6 +227,22 @@ CACHED
|
|||
@store.read("views/test.host/functional_caching/inline_fragment_cached/#{template_digest("functional_caching/inline_fragment_cached")}"))
|
||||
end
|
||||
|
||||
def test_fragment_cache_instrumentation
|
||||
payload = nil
|
||||
|
||||
subscriber = proc do |*args|
|
||||
event = ActiveSupport::Notifications::Event.new(*args)
|
||||
payload = event.payload
|
||||
end
|
||||
|
||||
ActiveSupport::Notifications.subscribed(subscriber, "read_fragment.action_controller") do
|
||||
get :inline_fragment_cached
|
||||
end
|
||||
|
||||
assert_equal "functional_caching", payload[:controller]
|
||||
assert_equal "inline_fragment_cached", payload[:action]
|
||||
end
|
||||
|
||||
def test_html_formatted_fragment_caching
|
||||
get :formatted_fragment_cached, :format => "html"
|
||||
assert_response :success
|
||||
|
|
Loading…
Reference in a new issue