Module: Skywalking::Plugins::Redis5::Redis5Intercept

Defined in:
lib/skywalking/plugins/redis5.rb

Instance Method Summary collapse

Instance Method Details

#_endpoint_infoObject



41
42
43
44
45
# File 'lib/skywalking/plugins/redis5.rb', line 41

def _endpoint_info
  "#{_redis_cfg.host}:#{_redis_cfg.port}"
rescue
  "Unknown"
end

#_redis_cfgObject



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/skywalking/plugins/redis5.rb', line 47

def _redis_cfg
  @redis_cfg ||= begin
    config = if defined?(::Redis::Client) && is_a?(::Redis::Client)
               self
             elsif respond_to?(:client)
               client&.config
             elsif defined?(::RedisClient)
               ::RedisClient.config if ::RedisClient.respond_to?(:config)
             end
    raise "Redis config not found" unless config
    config
  end
end

#call_v(args, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/skywalking/plugins/redis5.rb', line 20

def call_v(args, &block)
  operation = args[0] rescue "UNKNOWN"
  return super if operation == :auth

  Tracing::ContextManager.new_exit_span(
    operation: "Redis/#{operation.upcase}",
    peer: _endpoint_info,
    component: Tracing::Component::Redis
  ) do |span|
    span&.tag(Tracing::TagCacheType.new("Redis"))
    span&.tag(Tracing::TagCacheOp.new(operation))
    span&.layer = Tracing::Layer::Cache

    begin
      super(args, &block)
    rescue
      span&.error_occurred = true
    end
  end
end