Sha256: 811f03859761b3d019433eb73064a79e31d28520d8be2f1318941ea30f24c495

Contents?: true

Size: 656 Bytes

Versions: 5

Compression:

Stored size: 656 Bytes

Contents

module Librato
  module Rails
    module Subscribers

      # SQL

      ActiveSupport::Notifications.subscribe 'sql.active_record' do |*args|
        payload = args.last

        collector.group "rails.sql" do |s|
          # puts (event.payload[:name] || 'nil') + ":" + event.payload[:sql] + "\n"
          s.increment 'queries'

          sql = payload[:sql].strip
          s.increment 'selects' if sql.starts_with?('SELECT')
          s.increment 'inserts' if sql.starts_with?('INSERT')
          s.increment 'updates' if sql.starts_with?('UPDATE')
          s.increment 'deletes' if sql.starts_with?('DELETE')
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
librato-rails-0.10.3 lib/librato/rails/subscribers/sql.rb
librato-rails-0.10.2 lib/librato/rails/subscribers/sql.rb
librato-rails-0.10.1 lib/librato/rails/subscribers/sql.rb
librato-rails-0.10.0 lib/librato/rails/subscribers/sql.rb
librato-rails-0.10.0.pre1 lib/librato/rails/subscribers/sql.rb