Method: NewRelic::Agent::SqlSampler#notice_sql
- Defined in:
- lib/new_relic/agent/sql_sampler.rb
permalink #notice_sql(sql, metric_name, config, duration, state = nil, explainer = nil, binds = nil, name = nil) ⇒ Object
Deprecated.
Use Datastores.notice_sql instead.
Records an SQL query, potentially creating a new slow SQL trace, or aggregating the query into an existing slow SQL trace.
This method should be used only by gem authors wishing to extend the Ruby agent to instrument new database interfaces - it should generally not be called directly from application code.
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 142 def notice_sql(sql, metric_name, config, duration, state = nil, explainer = nil, binds = nil, name = nil) # THREAD_LOCAL_ACCESS sometimes 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") statement = Database::Statement.new(sql, config, explainer, binds, name) data.sql_data << SlowSql.new(statement, metric_name, duration, backtrace) end end end |