class Mongo::Collection
Public Instance Methods
collect_kvs(op, args)
click to toggle source
Used to collect up information to report and build a hash with the Keys/Values to report.
# File lib/traceview/inst/mongo2.rb, line 30 def collect_kvs(op, args) kvs = { :Flavor => :mongodb, :Database => @database.name } kvs[:QueryOp] = op if op == :create kvs[:New_Collection_Name] = @name else kvs[:Collection] = @name end if op == :map_reduce kvs[:Map_Function] = args[0] kvs[:Reduce_Function] = args[1] kvs[:Limit] = args[2][:limit] if args[2].is_a?(Hash) && args[2].key?(:limit) end if TraceView::Config[:mongo][:log_args] if COLL_QUERY_OPS.include?(op) kvs[:Query] = args.first.to_json end end kvs[:RemoteHost] = @database.client.cluster.addresses.first.to_s kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:mongo][:collect_backtraces] rescue => e TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if TraceView::Config[:verbose] ensure return kvs end
traceview_collect(m, args)
click to toggle source
# File lib/traceview/inst/mongo.rb, line 122 def traceview_collect(m, args) kvs = {} kvs[:Flavor] = TraceView::Inst::Mongo::FLAVOR kvs[:Database] = @db.name kvs[:RemoteHost] = @db.connection.host kvs[:RemotePort] = @db.connection.port kvs[:Collection] = @name kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:mongo][:collect_backtraces] kvs[:QueryOp] = m kvs[:Query] = args[0].to_json if args && !args.empty? && args[0].class == Hash rescue StandardError => e TraceView.logger.debug "[traceview/debug] Exception in traceview_collect KV collection: #{e.inspect}" ensure return kvs end