Module: NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions4x

Defined in:
lib/new_relic/agent/instrumentation/active_record_notifications.rb

Instance Method Summary collapse

Instance Method Details

#log(sql, name = 'SQL', binds = [], statement_name = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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