17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/one_apm/agent/datastore.rb', line 17
def self.trace(clazz, method_name, product, operation = method_name)
clazz.class_eval do
method_name_without_oneapm = "#{method_name}_without_oneapm"
if OneApm::Helper.instance_methods_include?(clazz, method_name) &&
!OneApm::Helper.instance_methods_include?(clazz, method_name_without_oneapm)
visibility = OneApm::Helper.instance_method_visibility(clazz, method_name)
alias_method method_name_without_oneapm, method_name
define_method(method_name) do |*args, &blk|
metrics = MetricHelper.metrics_for(product, operation)
OneApm::Support::MethodTracer.trace_execution_scoped(metrics) do
send(method_name_without_oneapm, *args, &blk)
end
end
send visibility, method_name
send visibility, method_name_without_oneapm
end
end
end
|