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

- old
+ new

@@ -4,13 +4,13 @@ module Oboe module Inst module Redis module Client # The operations listed in this constant skip collecting KVKey - NO_KEY_OPS = [ :keys, :randomkey, :scan, :sdiff, :sdiffstore, :sinter, - :sinterstore, :smove, :sunion, :sunionstore, :zinterstore, - :zunionstore, :publish, :select, :eval, :evalsha, :script ] + NO_KEY_OPS = [:keys, :randomkey, :scan, :sdiff, :sdiffstore, :sinter, + :sinterstore, :smove, :sunion, :sunionstore, :zinterstore, + :zunionstore, :publish, :select, :eval, :evalsha, :script] # Instead of a giant switch statement, we use a hash constant to map out what # KVs need to be collected for each of the many many Redis operations # Hash formatting by undiagnosed OCD KV_COLLECT_MAP = { @@ -36,11 +36,11 @@ :zrevrange => { :start => 2, :stop => 3 }, :hincrby => { :field => 2, :increment => 3 }, :smove => { :source => 1, :destination => 2 }, :bitop => { :operation => 1, :destkey => 2 }, :hincrbyfloat => { :field => 2, :increment => 3 }, - :zremrangebyrank => { :start => 2, :stop => 3 }, + :zremrangebyrank => { :start => 2, :stop => 3 } } # The following operations don't require any special handling. For these, # we only collect KVKey and KVOp # @@ -76,11 +76,11 @@ begin kvs[:KVOp] = command[0] kvs[:RemoteHost] = @options[:host] - unless NO_KEY_OPS.include? op or (command[1].is_a?(Array) and command[1].count > 1) + unless NO_KEY_OPS.include?(op) || (command[1].is_a?(Array) && command[1].count > 1) if command[1].is_a?(Array) kvs[:KVKey] = command[1].first else kvs[:KVKey] = command[1] end @@ -96,14 +96,14 @@ # by KV_COLLECT_MAP case op when :set if command.count > 3 options = command[3] - kvs[:ex] = options[:ex] if options.has_key?(:ex) - kvs[:px] = options[:px] if options.has_key?(:px) - kvs[:nx] = options[:nx] if options.has_key?(:nx) - kvs[:xx] = options[:xx] if options.has_key?(:xx) + kvs[:ex] = options[:ex] if options.key?(:ex) + kvs[:px] = options[:px] if options.key?(:px) + kvs[:nx] = options[:nx] if options.key?(:nx) + kvs[:xx] = options[:xx] if options.key?(:xx) end when :get kvs[:KVHit] = r.nil? ? 0 : 1 @@ -113,21 +113,21 @@ kvs[:KVHit] = r.nil? ? 0 : 1 end when :eval if command[1].length > 1024 - kvs[:Script] = command[1][0..1023] + "(...snip...)" + kvs[:Script] = command[1][0..1023] + '(...snip...)' else kvs[:Script] = command[1] end when :script kvs[:subcommand] = command[1] kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:redis][:collect_backtraces] - if command[1] == "load" + if command[1] == 'load' if command[1].length > 1024 - kvs[:Script] = command[2][0..1023] + "(...snip...)" + kvs[:Script] = command[2][0..1023] + '(...snip...)' else kvs[:Script] = command[2] end elsif command[1] == :exists if command[2].is_a?(Array) @@ -141,16 +141,16 @@ if command[1].is_a?(Array) kvs[:KVKeyCount] = command[1].count else kvs[:KVKeyCount] = command.count - 1 end - values = r.select{ |i| i } + values = r.select { |i| i } kvs[:KVHitCount] = values.count when :hmget kvs[:KVKeyCount] = command.count - 2 - values = r.select{ |i| i } + values = r.select { |i| i } kvs[:KVHitCount] = values.count when :mset, :msetnx if command[1].is_a?(Array) kvs[:KVKeyCount] = command[1].count / 2 @@ -160,11 +160,11 @@ end # case op end # if KV_COLLECT_MAP[op] rescue StandardError => e Oboe.logger.debug "Error collecting redis KVs: #{e.message}" - Oboe.logger.debug e.backtrace.join("\n") + Oboe.logger.debug e.backtrace.join('\n') end kvs end @@ -194,11 +194,11 @@ if command_count < 12 ops = [] pipeline.commands.each do |c| ops << c.first end - kvs[:KVOps] = ops.join(", ") + kvs[:KVOps] = ops.join(', ') end rescue StandardError => e Oboe.logger.debug "[oboe/debug] Error extracting pipelined commands: #{e.message}" Oboe.logger.debug e.backtrace end @@ -234,12 +234,10 @@ # The wrapper method for Redis::Client.call_pipeline. Here # (when tracing) we capture KVs to report and pass the call along # def call_pipeline_with_oboe(pipeline) if Oboe.tracing? - report_kvs = {} - # Fall back to the raw tracing API so we can pass KVs # back on exit (a limitation of the Oboe::API.trace # block method) This removes the need for an info # event to send additonal KVs ::Oboe::API.log_entry('redis', {}) @@ -263,11 +261,11 @@ end end end if Oboe::Config[:redis][:enabled] - if defined?(::Redis) and Gem::Version.new(::Redis::VERSION) >= Gem::Version.new('3.0.0') - Oboe.logger.info "[oboe/loading] Instrumenting redis" if Oboe::Config[:verbose] + if defined?(::Redis) && Gem::Version.new(::Redis::VERSION) >= Gem::Version.new('3.0.0') + Oboe.logger.info '[oboe/loading] Instrumenting redis' if Oboe::Config[:verbose] ::Oboe::Util.send_include(::Redis::Client, ::Oboe::Inst::Redis::Client) end end