Class: Moped::Database

Inherits:
Object
  • Object
show all
Includes:
Oboe::Inst::Moped
Defined in:
lib/oboe/inst/moped.rb

Constant Summary

Constants included from Oboe::Inst::Moped

Oboe::Inst::Moped::COLLECTION_OPS, Oboe::Inst::Moped::DB_OPS, Oboe::Inst::Moped::FLAVOR, Oboe::Inst::Moped::INDEX_OPS, Oboe::Inst::Moped::QUERY_OPS

Instance Method Summary collapse

Instance Method Details

#command_with_oboe(command) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/oboe/inst/moped.rb', line 50

def command_with_oboe(command)
  if Oboe.tracing? and not Oboe::Context.layer_op and command.has_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_oboeObject



68
69
70
71
72
73
74
75
76
# File 'lib/oboe/inst/moped.rb', line 68

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) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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
    report_kvs[:RemoteHost], report_kvs[:RemotePort] = session.cluster.seeds.first.split(':')
    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