Class: Moped::Collection

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

#aggregate_with_oboe(pipeline) ⇒ Object



434
435
436
437
438
439
440
441
442
# File 'lib/oboe/inst/moped.rb', line 434

def aggregate_with_oboe(pipeline)
  return aggregate_without_oboe(pipeline) unless Oboe.tracing?
    
  report_kvs = extract_trace_details(:aggregate)

  Oboe::API.trace('mongo', report_kvs) do
    aggregate_without_oboe(pipeline)
  end
end

#drop_with_oboeObject



385
386
387
388
389
390
391
392
393
394
395
# File 'lib/oboe/inst/moped.rb', line 385

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



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/oboe/inst/moped.rb', line 369

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[: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 = {}) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/oboe/inst/moped.rb', line 397

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_oboeObject



412
413
414
415
416
417
418
419
420
# File 'lib/oboe/inst/moped.rb', line 412

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



422
423
424
425
426
427
428
429
430
431
432
# File 'lib/oboe/inst/moped.rb', line 422

def insert_with_oboe(documents, flags = nil)
  if Oboe.tracing? and not Oboe::Context.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