# File lib/new_relic/agent/sql_sampler.rb, line 143
      def notice_sql(sql, metric_name, config, duration, state=nil, explainer=nil, binds=nil, name=nil) #THREAD_LOCAL_ACCESS sometimes
        state ||= TransactionState.tl_get
        data = state.sql_sampler_transaction_data
        return unless data

        if state.is_sql_recorded?
          if duration > Agent.config['slow_sql.explain_threshold''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