30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/one_apm/inst/nosql/mongo_moped.rb', line 30
def logging_with_oneapm_trace(operations, &blk)
operation_name, collection = determine_operation_and_collection(operations.first)
log_statement = operations.first.log_inspect.encode("UTF-8")
operation = case operation_name
when 'INSERT', 'UPDATE', 'CREATE', 'FIND_AND_MODIFY' then 'save'
when 'QUERY', 'COUNT', 'GET_MORE', 'AGGREGATE' then 'find'
when 'DELETE' then 'destroy'
else
nil
end
command = Proc.new { logging_without_oneapm_trace(operations, &blk) }
res = nil
if operation
callback = Proc.new do |result, metric, elapsed|
OneApm::Agent::Datastore.notice_statement(log_statement, elapsed)
end
OneApm::Agent::Datastore.wrap('MongoDB', operation, collection, callback) do
res = command.call
end
else
res = command.call
end
res
end
|