lib/remnant/rails.rb in remnant-0.3.3 vs lib/remnant/rails.rb in remnant-0.4.0

- old
+ new

@@ -31,16 +31,35 @@ # stat collection below # # hook remnants Remnant::Discover.find('request', ActionController::Dispatcher, :call) - Remnant::Discover.find('filters', ActionController::Filters::BeforeFilter, :call) Remnant::Discover.find('action', ActionController::Base, :perform_action) Remnant::Discover.find('view', ActionController::Base, :render) - Remnant::Discover.find('filters', ActionController::Filters::AfterFilter, :call) # + # Filter capturing + # + [ + ActionController::Filters::BeforeFilter, + ActionController::Filters::AfterFilter, + ActionController::Filters::AroundFilter + ].map do |remnant_constant| + Remnant::Discover.find_with(remnant_constant) do + remnant_constant.class_eval do + def call_with_remnant(*args, &block) + ::Remnant::Filters.record(self.class.to_s, method.to_s) do + call_without_remnant(*args, &block) + end + end + + alias_method_chain :call, :remnant + end + end + end + + # # Template rendering # if defined?(ActionView) && defined?(ActionView::Template) Remnant::Discover.find_with(ActionView::Template) do ActionView::Template.class_eval do @@ -73,12 +92,15 @@ end # last hook into request cycle for sending results ::ActionController::Dispatcher.class_eval do def call_with_remnant_discovery(*args, &block) #:nodoc: + ::Remnant::GC.enable_stats call_without_remnant_discovery(*args, &block).tap do |status, headers, response| + ::Remnant::GC.disable_stats begin ::Remnant.collect + ::Remnant::GC.clear_stats ::Rails.logger.flush if ::Rails.logger.respond_to? :flush rescue Exception => e if defined?(::Flail) Flail::Exception.notify(e) else