Sha256: 6b83afb5a49be8ae5beb577c076610b878c4bc8772f5b590e9bfc0eb9c2d0127

Contents?: true

Size: 646 Bytes

Versions: 12

Compression:

Stored size: 646 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 (payload[:name] || 'nil') + ":" + payload[:sql] + "\n\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

12 entries across 12 versions & 1 rubygems

Version Path
librato-rails-1.4.2 lib/librato/rails/subscribers/sql.rb
librato-rails-1.4.1 lib/librato/rails/subscribers/sql.rb
librato-rails-1.4.0 lib/librato/rails/subscribers/sql.rb
librato-rails-1.4.0.beta lib/librato/rails/subscribers/sql.rb
librato-rails-1.3.0 lib/librato/rails/subscribers/sql.rb
librato-rails-1.2.0 lib/librato/rails/subscribers/sql.rb
librato-rails-1.1.0 lib/librato/rails/subscribers/sql.rb
librato-rails-1.0.0 lib/librato/rails/subscribers/sql.rb
librato-rails-0.12.0 lib/librato/rails/subscribers/sql.rb
librato-rails-0.12.0.beta lib/librato/rails/subscribers/sql.rb
librato-rails-0.11.1 lib/librato/rails/subscribers/sql.rb
librato-rails-0.11.0 lib/librato/rails/subscribers/sql.rb