class Moped::Collection

Public Instance Methods

aggregate_with_oboe(*pipeline) click to toggle source
# File lib/oboe/inst/moped.rb, line 453
def aggregate_with_oboe(*pipeline)
  return aggregate_without_oboe(pipeline) unless Oboe.tracing?

  report_kvs = extract_trace_details(:aggregate)
  report_kvs[:Query] = pipeline

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

  # We report :drop_collection here to be consistent
  # with other mongo implementations
  report_kvs = extract_trace_details(:drop_collection)

  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 383
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[:Collection] = 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
find_with_oboe(selector = {}) click to toggle source
# File lib/oboe/inst/moped.rb, line 416
def find_with_oboe(selector = {})
  return find_without_oboe(selector) unless Oboe.tracing?

  begin
    report_kvs = extract_trace_details(:find)
    report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json
  rescue StandardError => e
    Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
  end

  Oboe::API.trace('mongo', report_kvs) do
    find_without_oboe(selector)
  end
end
indexes_with_oboe() click to toggle source
# File lib/oboe/inst/moped.rb, line 431
def indexes_with_oboe
  return indexes_without_oboe unless Oboe.tracing?

  report_kvs = extract_trace_details(:indexes)

  Oboe::API.trace('mongo', report_kvs) do
    indexes_without_oboe
  end
end
insert_with_oboe(documents, flags = nil) click to toggle source
# File lib/oboe/inst/moped.rb, line 441
def insert_with_oboe(documents, flags = nil)
  if Oboe.tracing? && !Oboe.tracing_layer_op?(:create_index)
    report_kvs = extract_trace_details(:insert)

    Oboe::API.trace('mongo', report_kvs) do
      insert_without_oboe(documents, flags)
    end
  else
    insert_without_oboe(documents, flags)
  end
end