module TraceView::Inst::MopedIndexes
Public Class Methods
included(klass)
click to toggle source
# File lib/traceview/inst/moped.rb, line 103 def self.included(klass) TraceView::Inst::Moped::INDEX_OPS.each do |m| ::TraceView::Util.method_alias(klass, m) end end
Public Instance Methods
create_with_traceview(key, options = {})
click to toggle source
# File lib/traceview/inst/moped.rb, line 129 def create_with_traceview(key, options = {}) return create_without_traceview(key, options) unless TraceView.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 TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" end TraceView::API.trace(:mongo, report_kvs, :create_index) do create_without_traceview(key, options = {}) end end
drop_with_traceview(key = nil)
click to toggle source
# File lib/traceview/inst/moped.rb, line 147 def drop_with_traceview(key = nil) return drop_without_traceview(key) unless TraceView.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 TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" end TraceView::API.trace(:mongo, report_kvs) do drop_without_traceview(key = nil) end end
extract_trace_details(op)
click to toggle source
# File lib/traceview/inst/moped.rb, line 109 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 first = database.session.cluster.seeds.first if ::Moped::VERSION < '2.0.0' report_kvs[:RemoteHost] = first else report_kvs[:RemoteHost] = "#{first.address.host}:#{first.address.port}" end report_kvs[:Database] = database.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