class Moped::Indexes

Public Instance Methods

create_with_oboe(key, options = {}) click to toggle source
# File lib/oboe/inst/moped.rb, line 119
def create_with_oboe(key, options = {})
  return create_without_oboe(key, options = {}) unless 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 StandardError => 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
end
drop_with_oboe(key = nil) click to toggle source
# File lib/oboe/inst/moped.rb, line 137
def drop_with_oboe(key = nil)
  return drop_without_oboe(key = nil) unless 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 StandardError => 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
end
extract_trace_details(op) click to toggle source
# File lib/oboe/inst/moped.rb, line 99
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] = database.session.cluster.seeds.first.split(':')
    else
      report_kvs[:RemoteHost] = database.session.cluster.seeds.first.address.host
      report_kvs[:RemotePort] = database.session.cluster.seeds.first.address.port
    end
    report_kvs[:Database] = 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