Commit b64a08b4 authored by coder-yqj's avatar coder-yqj Committed by 吴晟
Browse files

修改 JedisShardInfo 方式创建 jedis客户端时,无法拦截的bug (#1290)

parent 7cf67ffa
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName
public class JedisInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {

    private static final String HOST_AND_PORT_ARG_TYPE_NAME = "redis.clients.jedis.HostAndPort";
    private static final String JEDIS_SHARD_INFO_ARG_TYPE_NAME = "redis.clients.jedis.JedisShardInfo";
    private static final String ENHANCE_CLASS = "redis.clients.jedis.Jedis";
    private static final String CONSTRUCTOR_WITH_STRING_ARG_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v2.JedisConstructorWithStringArgInterceptor";
    private static final String CONSTRUCTOR_WITH_SHARD_INFO_ARG_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v2.JedisConstructorWithShardInfoArgInterceptor";
@@ -70,6 +71,17 @@ public class JedisInstrumentation extends ClassInstanceMethodsEnhancePluginDefin
                    return CONSTRUCTOR_WITH_SHARD_INFO_ARG_INTERCEPT_CLASS;
                }
            },
            new ConstructorInterceptPoint() {
                @Override
                 public ElementMatcher<MethodDescription> getConstructorMatcher() {
                    return takesArgumentWithType(0, JEDIS_SHARD_INFO_ARG_TYPE_NAME);
                }

                @Override
                public String getConstructorInterceptor() {
                    return CONSTRUCTOR_WITH_SHARD_INFO_ARG_INTERCEPT_CLASS;
                }
            },
            new ConstructorInterceptPoint() {
                @Override
                public ElementMatcher<MethodDescription> getConstructorMatcher() {