Sha256: 1a9334c7f3d1c54c64d754ad98698a6e5717b793c9a3d6994a8dc0e562dca464

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

module Librato
  module Rails
    module Subscribers

      # SQL

      ActiveSupport::Notifications.subscribe "sql.active_record" do |*args|

        payload = args.last
        sql = payload[:sql].strip

        collector.group "rails.sql" do |s|
          s.increment "queries"
          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 group

      end # end subscribe

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
librato-rails-2.1.0 lib/librato/rails/subscribers/sql.rb
librato-rails-2.0.0 lib/librato/rails/subscribers/sql.rb