Method: NewRelic::Agent::Datastores.notice_statement

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

.notice_statement(statement, elapsed) ⇒ Object

Note:

THERE ARE SECURITY CONCERNS WHEN CAPTURING STATEMENTS! This method will properly ignore statements when the user has turned off capturing queries, but it is not able to obfuscate arbitrary data! To prevent exposing user information embedded in captured queries, please ensure all data passed to this method is safe to transmit to New Relic.

Wrapper for simplifying attaching non-SQL data statements to a transaction. For instance, Mongo or CQL queries, Memcached or Redis keys would all be appropriate data to attach as statements.

Data passed to this method is NOT obfuscated by New Relic, so please ensure that user information is obfuscated if the agent setting ‘transaction_tracer.record_sql` is set to `obfuscated`

NewRelic::Agent::Datastores.notice_statement("key", elapsed)

Parameters:

  • statement (String)

    text of the statement to capture.

  • elapsed (Float)

    the elapsed time during query execution


194
195
196
197
198
199
200
201
202
203
# File 'lib/new_relic/agent/datastores.rb', line 194

def self.notice_statement(statement, elapsed)
  NewRelic::Agent.record_api_supportability_metric(:notice_statement)

  # Settings may change eventually, but for now we follow the same
  # capture rules as SQL for non-SQL statements.
  if (txn = Tracer.current_transaction) && (segment = txn.current_segment) && segment.respond_to?(:notice_nosql_statement)
    segment.notice_nosql_statement(statement)
  end
  nil
end