module AllSeeingEye::Integrations::Rails2
Public Instance Methods
log_request() { || ... }
click to toggle source
# File lib/all_seeing_eye/integrations/rails2.rb, line 4 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, Errno::EAGAIN Rails.logger.info('+++ Request not watched by AllSeeingEye; it took too long to complete or the server was unreachable') end end