diff options
author | Daniel Schierbeck <dasch@zendesk.com> | 2014-02-21 10:28:51 +0000 |
---|---|---|
committer | Daniel Schierbeck <dasch@zendesk.com> | 2014-05-10 09:35:29 +0000 |
commit | 92fbbf67e339f24f9203d9927c028ee052685377 (patch) | |
tree | 9c8def33aac3722be2865af8bd842d5b05b0eda9 | |
parent | b231825f3e0b569e5ca1426833749b5c6325ba14 (diff) | |
download | rails-92fbbf67e339f24f9203d9927c028ee052685377.tar.gz rails-92fbbf67e339f24f9203d9927c028ee052685377.tar.bz2 rails-92fbbf67e339f24f9203d9927c028ee052685377.zip |
Add controller and action name to the instrumentation payload
-rw-r--r-- | actionpack/CHANGELOG.md | 8 | ||||
-rw-r--r-- | actionpack/lib/action_controller/caching/fragments.rb | 8 | ||||
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 16 |
3 files changed, 31 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index fd3f9eb72d..5a7c2b1fff 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -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. diff --git a/actionpack/lib/action_controller/caching/fragments.rb b/actionpack/lib/action_controller/caching/fragments.rb index 879d5fdd94..9c697d94d5 100644 --- a/actionpack/lib/action_controller/caching/fragments.rb +++ b/actionpack/lib/action_controller/caching/fragments.rb @@ -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 diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 58a86ce9af..c0e6a2ebd1 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -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 |