lib/new_relic/agent/datastores.rb in newrelic_rpm-7.2.0 vs lib/new_relic/agent/datastores.rb in newrelic_rpm-8.0.0
- old
+ new
@@ -19,11 +19,11 @@
# Add Datastore tracing to a method. This properly generates the metrics
# for New Relic's Datastore features. It does not capture the actual
# query content into Transaction Traces. Use wrap if you want to provide
# that functionality.
#
- # @param [Class] clazz the class to instrument
+ # @param [Class] klass the class to instrument
#
# @param [String, Symbol] method_name the name of instance method to
# instrument
#
# @param [String] product name of your datastore for use in metric naming, e.g. "Redis"
@@ -31,20 +31,20 @@
# @param [optional,String] operation the name of operation if different
# than the instrumented method name
#
# @api public
#
- def self.trace(clazz, method_name, product, operation = method_name)
+ def self.trace(klass, method_name, product, operation = method_name)
NewRelic::Agent.record_api_supportability_metric(:trace)
- clazz.class_eval do
+ klass.class_eval do
method_name_without_newrelic = "#{method_name}_without_newrelic"
- if NewRelic::Helper.instance_methods_include?(clazz, method_name) &&
- !NewRelic::Helper.instance_methods_include?(clazz, method_name_without_newrelic)
+ if NewRelic::Helper.instance_methods_include?(klass, method_name) &&
+ !NewRelic::Helper.instance_methods_include?(klass, method_name_without_newrelic)
- visibility = NewRelic::Helper.instance_method_visibility(clazz, method_name)
+ visibility = NewRelic::Helper.instance_method_visibility(klass, method_name)
alias_method method_name_without_newrelic, method_name
define_method(method_name) do |*args, &blk|
segment = NewRelic::Agent::Tracer.start_datastore_segment(
@@ -121,10 +121,10 @@
begin
result = yield
ensure
begin
if callback
- elapsed_time = (Time.now - segment.start_time).to_f
+ elapsed_time = Process.clock_gettime(Process::CLOCK_REALTIME) - segment.start_time
callback.call(result, segment.name, elapsed_time)
end
ensure
segment.finish if segment
end