module TraceView::Inst::MopedCollection
Public Class Methods
included(klass)
click to toggle source
# File lib/traceview/inst/moped.rb, line 376 def self.included(klass) TraceView::Inst::Moped::COLLECTION_OPS.each do |m| ::TraceView::Util.method_alias(klass, m) end end
Public Instance Methods
aggregate_with_traceview(*pipeline)
click to toggle source
# File lib/traceview/inst/moped.rb, line 446 def aggregate_with_traceview(*pipeline) return aggregate_without_traceview(*pipeline) unless TraceView.tracing? report_kvs = extract_trace_details(:aggregate) report_kvs[:Query] = pipeline TraceView::API.trace(:mongo, report_kvs) do aggregate_without_traceview(pipeline) end end
drop_with_traceview()
click to toggle source
# File lib/traceview/inst/moped.rb, line 397 def drop_with_traceview return drop_without_traceview unless TraceView.tracing? # We report :drop_collection here to be consistent # with other mongo implementations report_kvs = extract_trace_details(:drop_collection) TraceView::API.trace(:mongo, report_kvs) do drop_without_traceview end end
extract_trace_details(op)
click to toggle source
# File lib/traceview/inst/moped.rb, line 382 def extract_trace_details(op) report_kvs = {} report_kvs[:Flavor] = TraceView::Inst::Moped::FLAVOR # FIXME: We're only grabbing the first of potentially multiple servers here report_kvs[:RemoteHost] = remote_host(database.session.cluster.seeds.first) report_kvs[:Database] = database.name report_kvs[:Collection] = name report_kvs[:QueryOp] = op.to_s report_kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:moped][:collect_backtraces] rescue StandardError => e TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" ensure return report_kvs end
find_with_traceview(selector = {})
click to toggle source
# File lib/traceview/inst/moped.rb, line 409 def find_with_traceview(selector = {}) return find_without_traceview(selector) unless TraceView.tracing? begin report_kvs = extract_trace_details(:find) report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json rescue StandardError => e TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" end TraceView::API.trace(:mongo, report_kvs) do find_without_traceview(selector) end end
indexes_with_traceview()
click to toggle source
# File lib/traceview/inst/moped.rb, line 424 def indexes_with_traceview return indexes_without_traceview unless TraceView.tracing? report_kvs = extract_trace_details(:indexes) TraceView::API.trace(:mongo, report_kvs) do indexes_without_traceview end end
insert_with_traceview(documents, flags = nil)
click to toggle source
# File lib/traceview/inst/moped.rb, line 434 def insert_with_traceview(documents, flags = nil) if TraceView.tracing? && !TraceView.tracing_layer_op?(:create_index) report_kvs = extract_trace_details(:insert) TraceView::API.trace(:mongo, report_kvs) do insert_without_traceview(documents, flags) end else insert_without_traceview(documents, flags) end end