class AllSeeingEye module Integrations module Rails2 def log_request _start_time = DateTime.now yield _end_time = DateTime.now hash = {} begin Timeout::timeout(AllSeeingEye.configuration['timeout']) { AllSeeingEye::Request.fields.each do |field, options| object = options['object'] == 'controller' ? 'self' : options['object'] val = eval("#{object}#{options['method']}") hash[field] = val end hash['created_at'] = _end_time hash['time_spent'] = (_end_time - _start_time).to_f * 1000 AllSeeingEye::Request.create(hash) Rails.logger.info('+++ Request watched by AllSeeingEye') } rescue Timeout::Error Rails.logger.info('+++ Request not watched by AllSeeingEye; it took too long to complete') end end end end end ActionController::Base.send(:include, AllSeeingEye::Integrations::Rails2) ActionController::Base.send(:around_filter, :log_request)