lib/new_relic/agent/datastores.rb in newrelic_rpm-4.1.0.333 vs lib/new_relic/agent/datastores.rb in newrelic_rpm-4.2.0.334

- old
+ new

@@ -145,13 +145,14 @@ # information embedded within captured queries. # # @api public # def self.notice_sql(query, scoped_metric, elapsed) - agent = NewRelic::Agent.instance - agent.transaction_sampler.notice_sql(query, nil, elapsed) - agent.sql_sampler.notice_sql(query, scoped_metric, nil, elapsed) + state = TransactionState.tl_get + if (txn = state.current_transaction) && (segment = txn.current_segment) && segment.respond_to?(:notice_sql) + segment.notice_sql(query) + end nil end # Wrapper for simplifying attaching non-SQL data statements to a # transaction. For instance, Mongo or CQL queries, Memcached or Redis @@ -177,13 +178,13 @@ # @api public # def self.notice_statement(statement, elapsed) # Settings may change eventually, but for now we follow the same # capture rules as SQL for non-SQL statements. - return unless NewRelic::Agent::Database.should_record_sql? - - agent = NewRelic::Agent.instance - agent.transaction_sampler.notice_nosql_statement(statement, elapsed) + state = TransactionState.tl_get + if (txn = state.current_transaction) && (segment = txn.current_segment) && segment.respond_to?(:notice_nosql_statement) + segment.notice_nosql_statement(statement) + end nil end end end