Sha256: 75cd0b4c59d2bfcf67e00d434137302005019c8da34ccc1f5925516e046ebb5a

Contents?: true

Size: 1.83 KB

Versions: 54

Compression:

Stored size: 1.83 KB

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2017

module Instana
  module RedisInstrumentation
    def call(*args, &block)
      kv_payload = { redis: {} }
      dnt_spans = [:redis, :'resque-client', :'sidekiq-client']

      if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
        return super(*args, &block)
      end

      begin
        ::Instana.tracer.log_entry(:redis)

        begin
          kv_payload[:redis][:connection] = "#{self.host}:#{self.port}"
          kv_payload[:redis][:db] = db.to_s
          kv_payload[:redis][:command] = args[0][0].to_s.upcase
        rescue
          nil
        end

        super(*args, &block)
      rescue => e
        ::Instana.tracer.log_info({ redis: {error: true} })
        ::Instana.tracer.log_error(e)
        raise
      ensure
        ::Instana.tracer.log_exit(:redis, kv_payload)
      end
    end

    def call_pipeline(*args, &block)
      kv_payload = { redis: {} }
      dnt_spans = [:redis, :'resque-client', :'sidekiq-client']

      if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
        return super(*args, &block)
      end

      begin
        ::Instana.tracer.log_entry(:redis)

        pipeline = args.first
        begin
          kv_payload[:redis][:connection] = "#{self.host}:#{self.port}"
          kv_payload[:redis][:db] = db.to_s
          kv_payload[:redis][:command] = pipeline.is_a?(::Redis::Pipeline::Multi) ? 'MULTI' : 'PIPELINE'
        rescue
          nil
        end

        super(*args, &block)
      rescue => e
        ::Instana.tracer.log_info({ redis: {error: true} })
        ::Instana.tracer.log_error(e)
        raise
      ensure
        ::Instana.tracer.log_exit(:redis, kv_payload)
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
instana-1.207.0 lib/instana/instrumentation/redis.rb
instana-1.206.0 lib/instana/instrumentation/redis.rb
instana-1.205.0 lib/instana/instrumentation/redis.rb
instana-1.204.0 lib/instana/instrumentation/redis.rb
instana-1.204.0.pre3 lib/instana/instrumentation/redis.rb
instana-1.204.0.pre2 lib/instana/instrumentation/redis.rb
instana-1.204.0.pre1 lib/instana/instrumentation/redis.rb
instana-1.203.2 lib/instana/instrumentation/redis.rb
instana-1.203.1 lib/instana/instrumentation/redis.rb
instana-1.203.0 lib/instana/instrumentation/redis.rb
instana-1.202.0 lib/instana/instrumentation/redis.rb
instana-1.201.0 lib/instana/instrumentation/redis.rb
instana-1.201.0.pre1 lib/instana/instrumentation/redis.rb
instana-1.200.0 lib/instana/instrumentation/redis.rb
instana-1.200.0.pre1 lib/instana/instrumentation/redis.rb
instana-1.199.6 lib/instana/instrumentation/redis.rb
instana-1.199.5 lib/instana/instrumentation/redis.rb
instana-1.199.4 lib/instana/instrumentation/redis.rb
instana-1.199.3 lib/instana/instrumentation/redis.rb
instana-1.199.2 lib/instana/instrumentation/redis.rb