Sha256: b45be4b2a1c3080c360af84dd1f8ab80ca3abb55965ba7f40dbf25b6b5f0ae5c

Contents?: true

Size: 691 Bytes

Versions: 4

Compression:

Stored size: 691 Bytes

Contents

module RailsLiveDashboard
  module Subscribers
    class ActiveRecordSubscriber
      def initialize
        ActiveSupport::Notifications.subscribe 'sql.active_record' do |event|
          next if should_skip(event)

          Recorders::QueryRecorder.new(event).execute
        rescue StandardError => e
          Rails.logger.error "ActionRecordSubscriber - Error on handle active record event: #{e.message}"
        end
      end

      private

      def should_skip(event)
        event.payload[:name].blank? ||
          event.payload[:name].match(/SCHEMA|TRANSACTION|ActiveRecord|RailsLiveDashboard/) ||
          event.payload[:sql].match(/BEGIN|COMMIT/)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_live_dashboard-0.2.0 lib/rails_live_dashboard/subscribers/active_record_subscriber.rb
rails_live_dashboard-0.1.2 lib/rails_live_dashboard/subscribers/active_record_subscriber.rb
rails_live_dashboard-0.1.1 lib/rails_live_dashboard/subscribers/active_record_subscriber.rb
rails_live_dashboard-0.1.0 lib/rails_live_dashboard/subscribers/active_record_subscriber.rb