lib/new_relic/agent/datastores.rb in newrelic_rpm-5.7.0.350 vs lib/new_relic/agent/datastores.rb in newrelic_rpm-6.0.0.351
- old
+ new
@@ -45,11 +45,11 @@
visibility = NewRelic::Helper.instance_method_visibility(clazz, method_name)
alias_method method_name_without_newrelic, method_name
define_method(method_name) do |*args, &blk|
- segment = NewRelic::Agent::Transaction.start_datastore_segment(
+ segment = NewRelic::Agent::Tracer.start_datastore_segment(
product: product,
operation: operation
)
begin
send(method_name_without_newrelic, *args, &blk)
@@ -110,23 +110,23 @@
def self.wrap(product, operation, collection = nil, callback = nil)
NewRelic::Agent.record_api_supportability_metric(:wrap)
return yield unless operation
- segment = NewRelic::Agent::Transaction.start_datastore_segment(
+ segment = NewRelic::Agent::Tracer.start_datastore_segment(
product: product,
operation: operation,
collection: collection
)
begin
result = yield
ensure
begin
if callback
- elapsed_time = (Time.now - segment.start_time).to_f
- callback.call(result, segment.name, elapsed_time)
+ elapsed_time = (Time.now - segment.start_time).to_f
+ callback.call(result, segment.name, elapsed_time)
end
ensure
segment.finish if segment
end
end
@@ -161,12 +161,11 @@
# @api public
#
def self.notice_sql(query, scoped_metric, elapsed)
NewRelic::Agent.record_api_supportability_metric(:notice_sql)
- state = TransactionState.tl_get
- if (txn = state.current_transaction) && (segment = txn.current_segment) && segment.respond_to?(:notice_sql)
+ if (txn = Tracer.current_transaction) && (segment = txn.current_segment) && segment.respond_to?(:notice_sql)
segment.notice_sql(query)
end
nil
end
@@ -196,11 +195,10 @@
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.
- state = TransactionState.tl_get
- if (txn = state.current_transaction) && (segment = txn.current_segment) && segment.respond_to?(:notice_nosql_statement)
+ if (txn = Tracer.current_transaction) && (segment = txn.current_segment) && segment.respond_to?(:notice_nosql_statement)
segment.notice_nosql_statement(statement)
end
nil
end