lib/oboe/inst/moped.rb in oboe-2.7.1.7-java vs lib/oboe/inst/moped.rb in oboe-2.7.2.fuchs1

- old
+ new

@@ -7,27 +7,27 @@ module Inst module Moped FLAVOR = 'mongodb' # Moped::Database - DB_OPS = [ :command, :drop ] + DB_OPS = [:command, :drop] # Moped::Indexes - INDEX_OPS = [ :create, :drop ] + INDEX_OPS = [:create, :drop] # Moped::Query - QUERY_OPS = [ :count, :sort, :limit, :distinct, :update, :update_all, :upsert, - :explain, :modify, :remove, :remove_all ] + QUERY_OPS = [:count, :sort, :limit, :distinct, :update, :update_all, :upsert, + :explain, :modify, :remove, :remove_all] # Moped::Collection - COLLECTION_OPS = [ :drop, :find, :indexes, :insert, :aggregate ] + COLLECTION_OPS = [:drop, :find, :indexes, :insert, :aggregate] end end end -if defined?(::Moped) and Oboe::Config[:moped][:enabled] - Oboe.logger.info "[oboe/loading] Instrumenting moped" if Oboe::Config[:verbose] +if defined?(::Moped) && Oboe::Config[:moped][:enabled] + Oboe.logger.info '[oboe/loading] Instrumenting moped' if Oboe::Config[:verbose] if defined?(::Moped::Database) module ::Moped class Database include Oboe::Inst::Moped @@ -35,11 +35,11 @@ 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 - if ::Moped::VERSION < "2.0.0" + if ::Moped::VERSION < '2.0.0' report_kvs[:RemoteHost], report_kvs[:RemotePort] = session.cluster.seeds.first.split(':') else report_kvs[:RemoteHost] = session.cluster.seeds.first.address.host report_kvs[:RemotePort] = session.cluster.seeds.first.address.port end @@ -51,11 +51,11 @@ end report_kvs end def command_with_oboe(command) - if Oboe.tracing? and not Oboe.layer_op and command.has_key?(:mapreduce) + if Oboe.tracing? && !Oboe.layer_op && command.key?(:mapreduce) begin report_kvs = extract_trace_details(:map_reduce) report_kvs[:Map_Function] = command[:map] report_kvs[:Reduce_Function] = command[:reduce] rescue StandardError => e @@ -99,11 +99,11 @@ 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 - if ::Moped::VERSION < "2.0.0" + if ::Moped::VERSION < '2.0.0' report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':') else report_kvs[:RemoteHost] = database.session.cluster.seeds.first.address.host report_kvs[:RemotePort] = database.session.cluster.seeds.first.address.port end @@ -139,11 +139,11 @@ 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 + report_kvs[:Key] = key.nil? ? 'all' : key.to_json rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" end Oboe::API.trace('mongo', report_kvs) do @@ -170,11 +170,11 @@ 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 - if ::Moped::VERSION < "2.0.0" + if ::Moped::VERSION < '2.0.0' report_kvs[:RemoteHost], report_kvs[:RemotePort] = collection.database.session.cluster.seeds.first.split(':') else report_kvs[:RemoteHost] = collection.database.session.cluster.seeds.first.address.host report_kvs[:RemotePort] = collection.database.session.cluster.seeds.first.address.port end @@ -191,11 +191,11 @@ 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 + 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 @@ -206,11 +206,11 @@ 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[:Query] = selector.empty? ? 'all' : selector.to_json report_kvs[:Order] = sort.to_s rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" end @@ -218,14 +218,14 @@ sort_without_oboe(sort) end end def limit_with_oboe(limit) - if Oboe.tracing? and not Oboe.tracing_layer_op?(:explain) + if Oboe.tracing? && !Oboe.tracing_layer_op?(:explain) begin report_kvs = extract_trace_details(:limit) - report_kvs[:Query] = selector.empty? ? "all" : selector.to_json + report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json report_kvs[:Limit] = limit.to_s rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" end @@ -240,11 +240,11 @@ def distinct_with_oboe(key) return distinct_without_oboe(key) unless Oboe.tracing? begin report_kvs = extract_trace_details(:distinct) - report_kvs[:Query] = selector.empty? ? "all" : selector.to_json + report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json report_kvs[:Key] = key.to_s rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" end @@ -252,11 +252,11 @@ distinct_without_oboe(key) end end def update_with_oboe(change, flags = nil) - if Oboe.tracing? and not Oboe.tracing_layer_op?([:update_all, :upsert]) + if Oboe.tracing? && !Oboe.tracing_layer_op?([:update_all, :upsert]) begin report_kvs = extract_trace_details(:update) report_kvs[:Flags] = flags.to_s if flags report_kvs[:Update_Document] = change.to_json rescue StandardError => e @@ -305,11 +305,11 @@ 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 + 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, :explain) do @@ -320,11 +320,11 @@ def modify_with_oboe(change, options = {}) return modify_without_oboe(change, options) unless Oboe.tracing? begin report_kvs = extract_trace_details(:modify) - report_kvs[:Update_Document] = selector.empty? ? "all" : selector.to_json + report_kvs[:Update_Document] = selector.empty? ? 'all' : selector.to_json report_kvs[:Change] = change.to_json report_kvs[:Options] = options.to_json rescue StandardError => e Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}" end @@ -373,22 +373,21 @@ end end end end # ::Moped::Query - if defined?(::Moped::Collection) module ::Moped class Collection 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 - if ::Moped::VERSION < "2.0.0" + if ::Moped::VERSION < '2.0.0' report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':') else report_kvs[:RemoteHost] = database.session.cluster.seeds.first.address.host report_kvs[:RemotePort] = database.session.cluster.seeds.first.address.port end @@ -417,11 +416,11 @@ 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 + 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 @@ -438,10 +437,10 @@ indexes_without_oboe end end def insert_with_oboe(documents, flags = nil) - if Oboe.tracing? and not Oboe.tracing_layer_op?(:create_index) + if Oboe.tracing? && !Oboe.tracing_layer_op?(:create_index) report_kvs = extract_trace_details(:insert) Oboe::API.trace('mongo', report_kvs) do insert_without_oboe(documents, flags) end