Class: Moped::Indexes

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

#create_with_oboe(key, options = {}) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/oboe/inst/moped.rb', line 111

def create_with_oboe(key, options = {})
  if Oboe.tracing?
    begin
      # We report :create_index here to be consistent
      # with other mongo implementations
      report_kvs = extract_trace_details(:create_index)
      report_kvs[:Key] = key.to_json
      report_kvs[:Options] = options.to_json
    rescue Exception => e
      Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
    end

    Oboe::API.trace('mongo', report_kvs, :create_index) do
      create_without_oboe(key, options = {})
    end
  else
    create_without_oboe(key, options = {})
  end
end

#drop_with_oboe(key = nil) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/oboe/inst/moped.rb', line 131

def drop_with_oboe(key = nil)
  if Oboe.tracing?
    begin
      # We report :drop_indexes here to be consistent
      # with other mongo implementations
      report_kvs = extract_trace_details(:drop_indexes)
      report_kvs[:Key] = key.nil? ? "all" : key.to_json
    rescue Exception => e
      Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
    end

    Oboe::API.trace('mongo', report_kvs) do
      drop_without_oboe(key = nil)
    end
  else
    drop_without_oboe(key = nil)
  end
end

#extract_trace_details(op) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/oboe/inst/moped.rb', line 96

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] = database.session.cluster.seeds.first.split(':')
    report_kvs[:Database] = database.name
    report_kvs[:QueryOp] = op.to_s
    report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
  rescue Exception => e
    Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
  end
  report_kvs
end