class Moped::Database

Public Instance Methods

command_with_oboe(command) click to toggle source
# File lib/oboe/inst/moped.rb, line 55
def command_with_oboe(command)
  if Oboe.tracing? && !Oboe.layer_op && command.key?(:mapreduce)
    begin
      report_kvs = extract_trace_details(:map_reduce)
      report_kvs[:Map_Function] = command[:map]
      report_kvs[:Reduce_Function] = command[:reduce]
    rescue StandardError => e
      Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
    end

    Oboe::API.trace('mongo', report_kvs) do
      command_without_oboe(command)
    end
  else
    command_without_oboe(command)
  end
end
drop_with_oboe() click to toggle source
# File lib/oboe/inst/moped.rb, line 73
def drop_with_oboe
  return drop_without_oboe unless Oboe.tracing?

  report_kvs = extract_trace_details(:drop_database)

  Oboe::API.trace('mongo', report_kvs) do
    drop_without_oboe
  end
end
extract_trace_details(op) click to toggle source
# File lib/oboe/inst/moped.rb, line 35
def extract_trace_details(op)
  report_kvs = {}
  begin
    report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
    # FIXME: We're only grabbing the first of potentially multiple servers here
    if ::Moped::VERSION < '2.0.0'
      report_kvs[:RemoteHost], report_kvs[:RemotePort] = session.cluster.seeds.first.split(':')
    else
      report_kvs[:RemoteHost] = session.cluster.seeds.first.address.host
      report_kvs[:RemotePort] = session.cluster.seeds.first.address.port
    end
    report_kvs[:Database] = name
    report_kvs[:QueryOp] = op.to_s
    report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
  rescue StandardError => e
    Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
  end
  report_kvs
end