Method: NewRelic::Agent::SqlSampler#notice_sql_statement

Defined in:
lib/new_relic/agent/sql_sampler.rb

#notice_sql_statement(statement, metric_name, duration) ⇒ Object

[View source]

170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/new_relic/agent/sql_sampler.rb', line 170

def notice_sql_statement(statement, metric_name, duration)
  state ||= Tracer.state
  data = state.sql_sampler_transaction_data
  return unless data

  if state.is_sql_recorded?
    if duration > Agent.config[:'slow_sql.explain_threshold']
      backtrace = caller.join("\n")
      params = distributed_trace_attributes(state)
      data.sql_data << SlowSql.new(statement, metric_name, duration, backtrace, params)
    end
  end
end