Module: Instana::RedisInstrumentation
- Defined in:
- lib/instana/instrumentation/redis.rb
Constant Summary collapse
- ORIGINAL_METHODS =
{ :call => ::Redis::Client.instance_method(:call), :call_pipeline => ::Redis::Client.instance_method(:call_pipeline) }.freeze
Instance Method Summary collapse
- #call(*args, **kwargs, &block) ⇒ Object
- #call_pipeline(*args, **kwargs, &block) ⇒ Object
- #call_v(*args, **kwargs, &block) ⇒ Object
- #call_with_instana(command, original_super, args, kwargs, &block) ⇒ Object
- #multi(*args, **kwargs, &block) ⇒ Object
- #pipelined(*args, **kwargs, &block) ⇒ Object
- #skip_instrumentation? ⇒ Boolean
Instance Method Details
#call(*args, **kwargs, &block) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/instana/instrumentation/redis.rb', line 43 def call(*args, **kwargs, &block) if skip_instrumentation? super(*args, **kwargs, &block) else call_with_instana(args[0][0].to_s.upcase, ORIGINAL_METHODS[:call], args, kwargs, &block) end end |
#call_pipeline(*args, **kwargs, &block) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/instana/instrumentation/redis.rb', line 51 def call_pipeline(*args, **kwargs, &block) if skip_instrumentation? super(*args, **kwargs, &block) else call_with_instana(args.first.is_a?(::Redis::Pipeline::Multi) ? 'MULTI' : 'PIPELINE', ORIGINAL_METHODS[:call_pipeline], args, kwargs, &block) end end |
#call_v(*args, **kwargs, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/instana/instrumentation/redis.rb', line 13 def call_v(*args, **kwargs, &block) if skip_instrumentation? super(*args, **kwargs, &block) else call_with_instana(args[0][0].to_s.upcase, ORIGINAL_METHODS[:call_v], args, kwargs, &block) end end |
#call_with_instana(command, original_super, args, kwargs, &block) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/instana/instrumentation/redis.rb', line 65 def call_with_instana(command, original_super, args, kwargs, &block) kv_payload = { redis: {} } begin ::Instana.tracer.start_span(:redis) begin kv_payload[:redis][:connection] = "#{self.host}:#{self.port}" kv_payload[:redis][:db] = db.to_s kv_payload[:redis][:command] = command rescue nil end original_super.bind(self).call(*args, **kwargs, &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 |
#multi(*args, **kwargs, &block) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/instana/instrumentation/redis.rb', line 29 def multi(*args, **kwargs, &block) if skip_instrumentation? super(*args, **kwargs, &block) else call_with_instana('MULTI', ORIGINAL_METHODS[:multi], args, kwargs, &block) end end |
#pipelined(*args, **kwargs, &block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/instana/instrumentation/redis.rb', line 21 def pipelined(*args, **kwargs, &block) if skip_instrumentation? super(*args, **kwargs, &block) else call_with_instana('PIPELINE', ORIGINAL_METHODS[:pipelined], args, kwargs, &block) end end |
#skip_instrumentation? ⇒ Boolean
60 61 62 63 |
# File 'lib/instana/instrumentation/redis.rb', line 60 def skip_instrumentation? dnt_spans = [:redis, :'resque-client', :'sidekiq-client'] !Instana.tracer.tracing? || (!::Instana.tracer.current_span.nil? && dnt_spans.include?(::Instana.tracer.current_span.name)) || !Instana.config[:redis][:enabled] end |