Method: NewRelic::Agent::Datastores.notice_sql

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

.notice_sql(query, scoped_metric, elapsed) ⇒ Object

Note:

THERE ARE SECURITY CONCERNS WHEN CAPTURING QUERY TEXT! New Relic’s Transaction Tracing and Slow SQL features will attempt to apply obfuscation to the passed queries, but it is possible for a query format to be unsupported and result in exposing user information embedded within captured queries.

Wrapper for simplifying attaching SQL queries during a transaction.

If you are recording non-SQL data, please use notice_statement instead.

NewRelic::Agent::Datastores.notice_sql(query, metrics, elapsed)

Parameters:

  • query (String)

    the SQL text to be captured. Note that depending on user settings, this string will be run through obfuscation, but some dialects of SQL (or non-SQL queries) are not guaranteed to be properly obfuscated by these routines!

  • scoped_metric (String)

    The most specific metric relating to this query. Typically the result of NewRelic::Agent::Datastores::MetricHelper#metrics_for

  • elapsed (Float)

    the elapsed time during query execution


162
163
164
165
166
167
168
169
# File 'lib/new_relic/agent/datastores.rb', line 162

def self.notice_sql(query, scoped_metric, elapsed)
  NewRelic::Agent.record_api_supportability_metric(:notice_sql)

  if (txn = Tracer.current_transaction) && (segment = txn.current_segment) && segment.respond_to?(:notice_sql)
    segment.notice_sql(query)
  end
  nil
end