aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-09-19 12:31:47 -0300
committerJosé Valim <jose.valim@gmail.com>2009-09-20 10:56:38 -0300
commit7cc1c2e71da1ad277acc7a7664321d2224a56bb8 (patch)
tree3a0aa4da485ebadb82f0e98d983994de02aa64f0 /actionpack/lib/action_controller
parent8f47f311b7665d74220baf1449b39dc4e70e13e2 (diff)
downloadrails-7cc1c2e71da1ad277acc7a7664321d2224a56bb8.tar.gz
rails-7cc1c2e71da1ad277acc7a7664321d2224a56bb8.tar.bz2
rails-7cc1c2e71da1ad277acc7a7664321d2224a56bb8.zip
Add Orchestra instrumentation to fragment and page caching.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/base.rb1
-rw-r--r--actionpack/lib/action_controller/caching/fragments.rb32
-rw-r--r--actionpack/lib/action_controller/caching/pages.rb20
3 files changed, 34 insertions, 19 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 0dae68c7b7..f5bd0a00a1 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -2,7 +2,6 @@ module ActionController
class Base < Metal
abstract!
- include AbstractController::Benchmarker
include AbstractController::Callbacks
include AbstractController::Logger
diff --git a/actionpack/lib/action_controller/caching/fragments.rb b/actionpack/lib/action_controller/caching/fragments.rb
index 4ef600bea0..59e24619e3 100644
--- a/actionpack/lib/action_controller/caching/fragments.rb
+++ b/actionpack/lib/action_controller/caching/fragments.rb
@@ -53,11 +53,11 @@ module ActionController #:nodoc:
return content unless cache_configured?
key = fragment_cache_key(key)
-
- self.class.benchmark "Cached fragment miss: #{key}" do
+ event = ActiveSupport::Orchestra.instrument(:write_fragment, :key => key) do
cache_store.write(key, content, options)
end
+ self.class.log_with_time("Cached fragment miss: #{key}", event.duration)
content
end
@@ -66,10 +66,12 @@ module ActionController #:nodoc:
return unless cache_configured?
key = fragment_cache_key(key)
-
- self.class.benchmark "Cached fragment hit: #{key}" do
+ event = ActiveSupport::Orchestra.instrument(:read_fragment, :key => key) do
cache_store.read(key, options)
end
+
+ self.class.log_with_time("Cached fragment hit: #{key}", event.duration)
+ event.result
end
# Check if a cached fragment from the location signified by <tt>key</tt> exists (see <tt>expire_fragment</tt> for acceptable formats)
@@ -77,10 +79,12 @@ module ActionController #:nodoc:
return unless cache_configured?
key = fragment_cache_key(key)
-
- self.class.benchmark "Cached fragment exists?: #{key}" do
+ event = ActiveSupport::Orchestra.instrument(:fragment_exist?, :key => key) do
cache_store.exist?(key, options)
end
+
+ self.class.log_with_time("Cached fragment exists?: #{key}", event.duration)
+ event.result
end
# Removes fragments from the cache.
@@ -103,17 +107,21 @@ module ActionController #:nodoc:
def expire_fragment(key, options = nil)
return unless cache_configured?
- key = key.is_a?(Regexp) ? key : fragment_cache_key(key)
+ key = fragment_cache_key(key) unless key.is_a?(Regexp)
+ message = nil
- if key.is_a?(Regexp)
- self.class.benchmark "Expired fragments matching: #{key.source}" do
+ event = ActiveSupport::Orchestra.instrument(:expire_fragment, :key => key) do
+ if key.is_a?(Regexp)
+ message = "Expired fragments matching: #{key.source}"
cache_store.delete_matched(key, options)
- end
- else
- self.class.benchmark "Expired fragment: #{key}" do
+ else
+ message = "Expired fragment: #{key}"
cache_store.delete(key, options)
end
end
+
+ self.class.log_with_time(message, event.duration)
+ event.result
end
end
end
diff --git a/actionpack/lib/action_controller/caching/pages.rb b/actionpack/lib/action_controller/caching/pages.rb
index bd3b5a5875..4fb154470f 100644
--- a/actionpack/lib/action_controller/caching/pages.rb
+++ b/actionpack/lib/action_controller/caching/pages.rb
@@ -62,21 +62,29 @@ module ActionController #:nodoc:
# expire_page "/lists/show"
def expire_page(path)
return unless perform_caching
+ path = page_cache_path(path)
- benchmark "Expired page: #{page_cache_file(path)}" do
- File.delete(page_cache_path(path)) if File.exist?(page_cache_path(path))
+ event = ActiveSupport::Orchestra.instrument(:expire_page, :path => path) do
+ File.delete(path) if File.exist?(path)
end
+
+ log_with_time("Expired page: #{path}", event.duration)
+ event.result
end
# Manually cache the +content+ in the key determined by +path+. Example:
# cache_page "I'm the cached content", "/lists/show"
def cache_page(content, path)
return unless perform_caching
+ path = page_cache_path(path)
- benchmark "Cached page: #{page_cache_file(path)}" do
- FileUtils.makedirs(File.dirname(page_cache_path(path)))
- File.open(page_cache_path(path), "wb+") { |f| f.write(content) }
+ event = ActiveSupport::Orchestra.instrument(:cache_page, :path => path) do
+ FileUtils.makedirs(File.dirname(path))
+ File.open(path, "wb+") { |f| f.write(content) }
end
+
+ log_with_time("Cached page: #{path}", event.duration)
+ event.result
end
# Caches the +actions+ using the page-caching approach that'll store the cache in a path within the page_cache_directory that
@@ -149,4 +157,4 @@ module ActionController #:nodoc:
end
end
end
-end \ No newline at end of file
+end