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

This commit is contained in:
coder-yqj 2018-05-30 20:37:24 +07:00 committed by 吴晟 Wu Sheng
parent 7cf67ffa60
commit b64a08b4e0
1 changed files with 12 additions and 0 deletions

View File

@ -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() {