41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/one_apm/agent/datastore.rb', line 41
def self.wrap(product, operation, collection = nil, callback = nil)
return yield unless operation
metrics = MetricHelper.metrics_for(product, operation, collection)
scoped_metric = metrics.first
OneApm::Support::MethodTracer.trace_execution_scoped(metrics) do
t0 = Time.now
begin
result = yield
ensure
if callback
elapsed_time = (Time.now - t0).to_f
callback.call(result, scoped_metric, elapsed_time)
end
end
end
end
|