lib/oboe/inst/moped.rb in oboe-2.6.6.1 vs lib/oboe/inst/moped.rb in oboe-2.6.7.1

- old
+ new

@@ -13,11 +13,11 @@ # Moped::Indexes INDEX_OPS = [ :create, :drop ] # Moped::Query - QUERY_OPS = [ :count, :sort, :limit, :distinct, :update, :update_all, :upsert, + QUERY_OPS = [ :count, :sort, :limit, :distinct, :update, :update_all, :upsert, :explain, :modify, :remove, :remove_all ] # Moped::Collection COLLECTION_OPS = [ :drop, :find, :indexes, :insert, :aggregate ] end @@ -29,11 +29,11 @@ if defined?(::Moped::Database) module ::Moped class Database include Oboe::Inst::Moped - + 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 @@ -44,11 +44,11 @@ rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" end report_kvs end - + def command_with_oboe(command) if Oboe.tracing? and not Oboe::Context.layer_op and command.has_key?(:mapreduce) begin report_kvs = extract_trace_details(:map_reduce) report_kvs[:Map_Function] = command[:map] @@ -72,11 +72,11 @@ Oboe::API.trace('mongo', report_kvs) do drop_without_oboe end end - + Oboe::Inst::Moped::DB_OPS.each do |m| if method_defined?(m) class_eval "alias #{m}_without_oboe #{m}" class_eval "alias #{m} #{m}_with_oboe" else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument moped (#{m}). Partial traces may occur." @@ -86,13 +86,13 @@ end end if defined?(::Moped::Indexes) module ::Moped - class Indexes + class Indexes include Oboe::Inst::Moped - + 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 @@ -103,11 +103,11 @@ rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" end report_kvs end - + def create_with_oboe(key, options = {}) return create_without_oboe(key, options = {}) unless Oboe.tracing? begin # We report :create_index here to be consistent @@ -121,14 +121,14 @@ Oboe::API.trace('mongo', report_kvs, :create_index) do create_without_oboe(key, options = {}) end end - + def drop_with_oboe(key = nil) return drop_without_oboe(key = nil) unless Oboe.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 @@ -170,14 +170,14 @@ rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" end report_kvs end - + def count_with_oboe return count_without_oboe unless Oboe.tracing? - + begin report_kvs = extract_trace_details(:count) report_kvs[:Query] = selector.empty? ? "all" : selector.to_json rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" @@ -188,11 +188,11 @@ end end def sort_with_oboe(sort) return sort_without_oboe(sort) unless Oboe.tracing? - + begin report_kvs = extract_trace_details(:sort) report_kvs[:Query] = selector.empty? ? "all" : selector.to_json report_kvs[:Order] = sort.to_s rescue StandardError => e @@ -201,11 +201,11 @@ Oboe::API.trace('mongo', report_kvs) do sort_without_oboe(sort) end end - + def limit_with_oboe(limit) if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:explain) begin report_kvs = extract_trace_details(:limit) report_kvs[:Query] = selector.empty? ? "all" : selector.to_json @@ -215,12 +215,12 @@ end Oboe::API.trace('mongo', report_kvs) do limit_without_oboe(limit) end - else - limit_without_oboe(limit) + else + limit_without_oboe(limit) end end def distinct_with_oboe(key) return distinct_without_oboe(key) unless Oboe.tracing? @@ -235,11 +235,11 @@ Oboe::API.trace('mongo', report_kvs) do distinct_without_oboe(key) end end - + def update_with_oboe(change, flags = nil) if Oboe.tracing? and not Oboe::Context.tracing_layer_op?([:update_all, :upsert]) begin report_kvs = extract_trace_details(:update) report_kvs[:Flags] = flags.to_s if flags @@ -253,14 +253,14 @@ end else update_without_oboe(change, flags = nil) end end - + def update_all_with_oboe(change) return update_all_without_oboe(change) unless Oboe.tracing? - + begin report_kvs = extract_trace_details(:update_all) report_kvs[:Update_Document] = change.to_json rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" @@ -271,11 +271,11 @@ end end def upsert_with_oboe(change) return upsert_without_oboe(change) unless Oboe.tracing? - + begin report_kvs = extract_trace_details(:upsert) report_kvs[:Query] = selector.to_json report_kvs[:Update_Document] = change.to_json rescue StandardError => e @@ -287,11 +287,11 @@ end end def explain_with_oboe return explain_without_oboe unless Oboe.tracing? - + begin report_kvs = extract_trace_details(:explain) report_kvs[:Query] = selector.empty? ? "all" : selector.to_json rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" @@ -316,11 +316,11 @@ Oboe::API.trace('mongo', report_kvs) do modify_without_oboe(change, options) end end - + def remove_with_oboe return remove_without_oboe unless Oboe.tracing? begin report_kvs = extract_trace_details(:remove) @@ -382,11 +382,11 @@ report_kvs end 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 @@ -394,11 +394,11 @@ end end 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}" @@ -406,21 +406,21 @@ Oboe::API.trace('mongo', report_kvs) do find_without_oboe(selector) end end - + 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 - + 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 @@ -428,20 +428,20 @@ end else insert_without_oboe(documents, flags) end end - + 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 - + Oboe::Inst::Moped::COLLECTION_OPS.each do |m| if method_defined?(m) class_eval "alias #{m}_without_oboe #{m}" class_eval "alias #{m} #{m}_with_oboe" else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument moped (#{m}). Partial traces may occur."