module NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions4x

Public Instance Methods

log(sql, name = 'SQL', binds = [], statement_name = nil) { || ... } click to toggle source

github.com/rails/rails/blob/4-1-stable/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L371

# File lib/new_relic/agent/instrumentation/active_record_notifications.rb, line 19
def log(sql, name = 'SQL', binds = [], statement_name = nil)
  @instrumenter.instrument(
    SQL_ACTIVE_RECORD,
    :sql => sql,
    :name => name,
    :connection_id => object_id,
    :connection => self,
    :statement_name => statement_name,
    :binds => binds
  ) { yield }
rescue => e
  # The translate_exception_class method got introduced in 4.1
  if ::ActiveRecord::VERSION::MINOR == 0
    raise translate_exception(e, sql)
  else
    raise translate_exception_class(e, sql)
  end
end