Sha256: 531ebf8e8bee4ac53ee1fa3ef96429a28524080b19a763e6efbe85d5518b8c65

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

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, Errno::EAGAIN
          Rails.logger.info('+++ Request not watched by AllSeeingEye; it took too long to complete or the server was unreachable')
        end
      end
    end
  end
end

ActionController::Base.send(:include, AllSeeingEye::Integrations::Rails2)
ActionController::Base.send(:around_filter, :log_request)

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
all_seeing_eye-0.1.1 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.1.0 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.20 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.19 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.18 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.17 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.16 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.15 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.14 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.13 lib/all_seeing_eye/integrations/rails2.rb
all_seeing_eye-0.0.12 lib/all_seeing_eye/integrations/rails2.rb