Sha256: acb99cbb57af0e6e30a673eb9df5e07858732dd0e54b8b415f85b78bde09715c
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
# encoding: utf-8 TingYun::Support::LibraryDetection.defer do named :redis depends_on do defined?(::Redis) end executes do TingYun::Agent.logger.info 'Installing Redis Instrumentation' require 'ting_yun/agent/transaction/transaction_state' end executes do require 'ting_yun/agent/datastore' ::Redis::Client.class_eval do def record_redis_duration(_1, _2, duration) state = TingYun::Agent::TransactionState.tl_get if state state.timings.rds_duration = state.timings.rds_duration + duration * 1000 end end call_method = ::Redis::Client.new.respond_to?(:call) ? :call : :raw_call_command def call_with_tingyun_trace(*args, &blk) operation = args[0].is_a?(Array) ? args[0][0] : args[0] TingYun::Agent::Datastore.wrap("Redis", operation, nil, method(:record_redis_duration)) do call_without_tingyun_trace(*args, &blk) end end alias_method :call_without_tingyun_trace, call_method alias_method call_method, :call_with_tingyun_trace if public_method_defined? :call_pipelined def call_pipelined_with_tingyun_trace(*args, &block) pipeline = args[0] operation = pipeline.is_a?(::Redis::Pipeline::Multi) ? 'multi' : 'pipeline' TingYun::Agent::Datastore.wrap("Redis", operation, nil, method(:record_redis_duration)) do call_pipelined_without_tingyun_trace(*args, &block) end end alias_method :call_pipelined_without_tingyun_trace, :call_pipelined alias_method :call_pipelined, :call_pipelined_with_tingyun_trace end if public_method_defined? :connect alias_method :connect_without_tingyun, :connect def connect(*args, &block) TingYun::Agent::Datastore.wrap("Redis", "connect", nil, method(:record_redis_duration)) do connect_without_tingyun(*args, &block) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tingyun_rpm-1.2.0 | lib/ting_yun/instrumentation/redis.rb |