13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/new_relic/agent/instrumentation/memcache.rb', line 13
def instrument_methods(the_class, method_names)
method_names.each do |method_name|
next unless the_class.method_defined? method_name.to_sym
the_class.class_eval <<-EOD
def #{method_name}_with_newrelic_trace(*args, &block)
metrics = ["Memcache/#{method_name}",
(NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'Memcache/allWeb' : 'Memcache/allOther')]
self.class.trace_execution_scoped(metrics) do
t0 = Time.now
begin
#{method_name}_without_newrelic_trace(*args, &block)
ensure
#{memcache_key_snippet(method_name)}
end
end
end
alias #{method_name}_without_newrelic_trace #{method_name}
alias #{method_name} #{method_name}_with_newrelic_trace
EOD
end
end
|