提交 5db289a2 编写于 作者: Z zhangxin

Modify the redis plugin using the new API

上级 316c09b0
package com.a.eye.skywalking.api.plugin.jedis.v2;
import com.a.eye.skywalking.model.Identification;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.assist.NoCocurrencyAceessObject;
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
public class JedisMethodInterceptor extends NoCocurrencyAceessObject {
protected static final String REDIS_CONN_INFO_KEY = "redisClusterConnInfo";
@Override
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
this.whenEnter(context, new Runnable() {
@Override public void run() {
/**
* redis server wouldn't process rpc context. ignore the
* return(ContextData) of sender's beforeSend
*/
Identification.IdentificationBuilder builder = Identification
.newBuilder()
.viewPoint(
context.get(REDIS_CONN_INFO_KEY, String.class)
+ " " + interceptorContext.methodName())
.spanType(RedisBuriedPointType.INSTANCE);
if (interceptorContext.allArguments().length > 0
&& interceptorContext.allArguments()[0] instanceof String) {
builder.businessKey("key="
+ interceptorContext.allArguments()[0]);
}
rpcClientInvokeMonitor.beforeInvoke(builder.build());
}
});
}
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
this.whenExist(context, new Runnable(){
@Override public void run() {
rpcClientInvokeMonitor.afterInvoke();
}
});
return ret;
}
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
rpcClientInvokeMonitor.occurException(t);
}
}
package com.a.eye.skywalking.api.plugin.jedis.v2;
import com.a.eye.skywalking.api.IBuriedPointType;
public enum RedisBuriedPointType implements IBuriedPointType {
INSTANCE;
@Override
public String getTypeName() {
return "Redis";
}
@Override
public CallType getCallType() {
return CallType.SYNC;
}
}
package com.a.eye.skywalking.api.plugin.jedis.v2.define;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.bytebuddy.AllObjectDefaultMethodsMatch;
import com.a.eye.skywalking.plugin.bytebuddy.ArgumentTypeNameMatch;
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import java.util.Set;
import static com.a.eye.skywalking.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static net.bytebuddy.matcher.ElementMatchers.*;
public class JedisClusterPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
@Override
public String enhanceClassName() {
return "redis.clients.jedis.JedisCluster";
}
@Override
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, Set.class);
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorInterceptor4SetArg";
}
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgumentWithType(0, "redis.clients.jedis.HostAndPort");
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorInterceptor4HostAndPortArg";
}
}};
}
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return any().and(not(AllObjectDefaultMethodsMatch.INSTANCE));
}
@Override
public String getMethodsInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor";
}
}};
}
}
package com.a.eye.skywalking.api.plugin.jedis.v2;
package com.a.eye.skywalking.plugin.jedis.v2;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import redis.clients.jedis.HostAndPort;
import static com.a.eye.skywalking.api.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO;
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOSTS;
/**
* Created by xin on 16-6-12.
* {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch
* from {@link HostAndPort} into {@link EnhancedClassInstanceContext#context}, and each host and port will spilt ;.
*
* @author zhangxin
*/
public class JedisClusterConstructorInterceptor4HostAndPortArg implements InstanceConstructorInterceptor {
public class JedisClusterConstructorWithHostAndPortArgInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
StringBuilder redisConnInfo = new StringBuilder();
HostAndPort hostAndPort = (HostAndPort) interceptorContext.allArguments()[0];
redisConnInfo.append(hostAndPort.toString()).append(";");
context.set(REDIS_CONN_INFO_KEY, redisConnInfo.toString());
context.set(KEY_OF_REDIS_CONN_INFO, redisConnInfo.toString());
context.set(KEY_OF_REDIS_HOSTS, hostAndPort.getHost());
}
}
package com.a.eye.skywalking.api.plugin.jedis.v2;
package com.a.eye.skywalking.plugin.jedis.v2;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import redis.clients.jedis.HostAndPort;
import java.util.Set;
import static com.a.eye.skywalking.api.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
import redis.clients.jedis.HostAndPort;
/**
* Created by xin on 16-6-12.
* {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch
* from {@link HostAndPort} collector into {@link EnhancedClassInstanceContext#context}, and each host and port will spilt ;.
*
* @author zhangxin
*/
public class JedisClusterConstructorInterceptor4SetArg implements InstanceConstructorInterceptor {
public class JedisClusterConstructorWithListHostAndPortArgInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
StringBuilder redisConnInfo = new StringBuilder();
StringBuilder redisHost = new StringBuilder();
Set<HostAndPort> hostAndPorts = (Set<HostAndPort>) interceptorContext.allArguments()[0];
for (HostAndPort hostAndPort : hostAndPorts) {
redisConnInfo.append(hostAndPort.toString()).append(";");
redisHost.append(hostAndPort.getHost()).append(";");
}
context.set(REDIS_CONN_INFO_KEY, redisConnInfo.toString());
context.set(JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO, redisConnInfo.toString());
context.set(JedisMethodInterceptor.KEY_OF_REDIS_HOSTS, redisHost);
}
}
package com.a.eye.skywalking.api.plugin.jedis.v2;
package com.a.eye.skywalking.plugin.jedis.v2;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import redis.clients.jedis.JedisShardInfo;
import static com.a.eye.skywalking.api.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
import redis.clients.jedis.JedisShardInfo;
/**
* Created by wusheng on 2016/12/1.
* {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch
* from {@link JedisShardInfo} argument into {@link EnhancedClassInstanceContext#context}.
*
* @author zhangxin
*/
public class JedisConstructorInterceptor4ShardInfoArg implements InstanceConstructorInterceptor {
public class JedisConstructorWithShardInfoArgInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
String redisConnInfo;
JedisShardInfo shardInfo = (JedisShardInfo) interceptorContext.allArguments()[0];
redisConnInfo = shardInfo.getHost() + ":" + shardInfo.getPort();
context.set(REDIS_CONN_INFO_KEY, redisConnInfo);
context.set(JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO, redisConnInfo);
context.set(JedisMethodInterceptor.KEY_OF_REDIS_HOSTS, shardInfo.getHost());
}
}
package com.a.eye.skywalking.api.plugin.jedis.v2;
package com.a.eye.skywalking.plugin.jedis.v2;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import static com.a.eye.skywalking.api.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
public class JedisConstructorInterceptor4StringArg implements InstanceConstructorInterceptor {
/**
* {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch
* from string argument into {@link EnhancedClassInstanceContext#context}.
*
* @author zhangxin
*/
public class JedisConstructorWithStringArgInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
......@@ -15,7 +19,8 @@ public class JedisConstructorInterceptor4StringArg implements InstanceConstructo
if (interceptorContext.allArguments().length > 1) {
redisConnInfo += ":" + interceptorContext.allArguments()[1];
}
context.set(REDIS_CONN_INFO_KEY, redisConnInfo);
context.set(JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO, redisConnInfo);
context.set(JedisMethodInterceptor.KEY_OF_REDIS_HOSTS, interceptorContext.allArguments()[0]);
}
}
package com.a.eye.skywalking.api.plugin.jedis.v2;
package com.a.eye.skywalking.plugin.jedis.v2;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import java.net.URI;
import static com.a.eye.skywalking.api.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
/**
* Created by wusheng on 2016/12/1.
* {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch
* from {@link URI} argument into {@link EnhancedClassInstanceContext#context}.
*
* @author zhangxin
*/
public class JedisConstructorInterceptor4UriArg implements InstanceConstructorInterceptor {
public class JedisConstructorWithUriArgInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
String redisConnInfo;
URI uri = (URI) interceptorContext.allArguments()[0];
redisConnInfo = uri.getHost() + ":" + uri.getPort();
context.set(REDIS_CONN_INFO_KEY, redisConnInfo);
context.set(JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO, redisConnInfo);
context.set(JedisMethodInterceptor.KEY_OF_REDIS_HOSTS, uri.getHost());
}
}
package com.a.eye.skywalking.plugin.jedis.v2;
import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.assist.NoCocurrencyAceessObject;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.tag.Tags;
/**
* {@link JedisMethodInterceptor} create span and set redis host and redis connection information
* from {@link EnhancedClassInstanceContext#context} to span tags.
*
* @author zhangxin
*/
public class JedisMethodInterceptor extends NoCocurrencyAceessObject {
/**
* The key name that redis connection information in {@link EnhancedClassInstanceContext#context}.
*/
protected static final String KEY_OF_REDIS_CONN_INFO = "REDIS_CONNECTION_INFO";
/**
* The key name that redis host in {@link EnhancedClassInstanceContext#context}.
*/
protected static final String KEY_OF_REDIS_HOSTS = "KEY_OF_REDIS_HOSTS";
@Override
public void beforeMethod(final EnhancedClassInstanceContext context, final InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
this.whenEnter(context, new Runnable() {
@Override
public void run() {
Span span = ContextManager.INSTANCE.createSpan(context.get(KEY_OF_REDIS_CONN_INFO, String.class) + " " + interceptorContext.methodName());
Tags.COMPONENT.set(span, "Redis");
Tags.PEER_HOST.set(span, (String) context.get(KEY_OF_REDIS_HOSTS));
Tags.SPAN_LAYER.asDB(span);
if (interceptorContext.allArguments().length > 0
&& interceptorContext.allArguments()[0] instanceof String) {
span.setTag("operation_key", (String) interceptorContext.allArguments()[0]);
}
}
});
}
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
this.whenExist(context, new Runnable() {
@Override
public void run() {
ContextManager.INSTANCE.stopSpan();
}
});
return ret;
}
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
ContextManager.INSTANCE.activeSpan().log(t);
}
}
package com.a.eye.skywalking.plugin.jedis.v2.define;
import com.a.eye.skywalking.api.plugin.bytebuddy.AllObjectDefaultMethodsMatch;
import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorWithListHostAndPortArgInterceptor;
import com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import java.util.Set;
import static com.a.eye.skywalking.api.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static net.bytebuddy.matcher.ElementMatchers.any;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
/**
* {@link JedisClusterInstrumentation} presents that skywalking will intercept all constructors and methods of {@link redis.clients.jedis.JedisCluster}.
* There are two intercept classes to intercept the constructor of {@link redis.clients.jedis.JedisCluster}.
* {@link com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorWithHostAndPortArgInterceptor} intercepts all constructor with argument {@link redis.clients.jedis.HostAndPort}
* and the other constructor will intercept by class {@link JedisClusterConstructorWithListHostAndPortArgInterceptor}.
* {@link JedisMethodInterceptor} will intercept all methods of {@link redis.clients.jedis.JedisCluster}
*
* @author zhangxin
*/
public class JedisClusterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
/**
* {@link redis.clients.jedis.HostAndPort} argument type name
*/
private static final String ARGUMENT_TYPE_NAME = "redis.clients.jedis.HostAndPort";
/**
* Enhance class
*/
private static final String ENHANCE_CLASS = "redis.clients.jedis.JedisCluster";
/**
* Class that intercept all constructors with arg.
*/
private static final String CONSTRUCTOR_WITH_LIST_HOSTANDPORT_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorWithListHostAndPortArgInterceptor";
/**
* Class that intercept all methods.
*/
private static final String METHOD_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor";
/**
* Class that intercept all constructors with {@link redis.clients.jedis.HostAndPort}
*/
private static final String CONSTRUCTOR_WITH_HOSTANDPORT_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorWithHostAndPortArgInterceptor";
@Override
public String enhanceClassName() {
return ENHANCE_CLASS;
}
@Override
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[]{new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, Set.class);
}
@Override
public String getConstructorInterceptor() {
return CONSTRUCTOR_WITH_LIST_HOSTANDPORT_ARG_INTERCEPT_CLASS;
}
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgumentWithType(0, ARGUMENT_TYPE_NAME);
}
@Override
public String getConstructorInterceptor() {
return CONSTRUCTOR_WITH_HOSTANDPORT_ARG_INTERCEPT_CLASS;
}
}};
}
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return any().and(not(AllObjectDefaultMethodsMatch.INSTANCE));
}
@Override
public String getMethodsInterceptor() {
return METHOD_INTERCEPT_CLASS;
}
}};
}
}
package com.a.eye.skywalking.api.plugin.jedis.v2.define;
package com.a.eye.skywalking.plugin.jedis.v2.define;
import com.a.eye.skywalking.api.plugin.bytebuddy.AllObjectDefaultMethodsMatch;
import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.bytebuddy.AllObjectDefaultMethodsMatch;
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithUriArgInterceptor;
import com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithShardInfoArgInterceptor;
import com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
import java.net.URI;
import static com.a.eye.skywalking.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static net.bytebuddy.matcher.ElementMatchers.*;
import static com.a.eye.skywalking.api.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
/**
* {@link JedisInstrumentation} presents that skywalking will intercept all constructors and methods of {@link redis.clients.jedis.Jedis}.
* There are three intercept classes to intercept the constructor of {@link redis.clients.jedis.Jedis}.
* {@link JedisConstructorWithShardInfoArgInterceptor} intercepts all constructor with argument {@link redis.clients.jedis.HostAndPort}
* ,the constructors with uri will intercept by class {@link JedisConstructorWithUriArgInterceptor} and
* the other constructor will intercept by class {@link JedisConstructorWithShardInfoArgInterceptor}.
* {@link JedisMethodInterceptor} will intercept all methods of {@link redis.clients.jedis.Jedis}.
*
* @author zhangxin
*/
public class JedisInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
/**
* {@link redis.clients.jedis.HostAndPort} argument type name
*/
private static final String HOST_AND_PROT_ARG_TYPE_NAME = "redis.clients.jedis.HostAndPort";
/**
* Enhance class
*/
private static final String ENHANCE_CLASS = "redis.clients.jedis.Jedis";
/**
* Class that intercept all constructors with string arg
*/
private static final String CONSTRUCTOR_WITH_STRING_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithStringArgInterceptor";
/**
* Class that intercept all constructors with shard info
*/
private static final String CONSTRUCTOR_WITH_SHARD_INFO_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithShardInfoArgInterceptor";
/**
* Class that intercept all constructors with uri arg
*/
private static final String CONSTRUCTOR_WITH_URI_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithUriArgInterceptor";
@Override
public String enhanceClassName() {
return "redis.clients.jedis.Jedis";
return ENHANCE_CLASS;
}
@Override
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
return new ConstructorInterceptPoint[]{new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, String.class);
......@@ -31,17 +67,17 @@ public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorInterceptor4StringArg";
return CONSTRUCTOR_WITH_STRING_ARG_INTERCEPT_CLASS;
}
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgumentWithType(0, "redis.clients.jedis.HostAndPort");
return takesArgumentWithType(0, HOST_AND_PROT_ARG_TYPE_NAME);
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorInterceptor4ShardInfoArgg";
return CONSTRUCTOR_WITH_SHARD_INFO_ARG_INTERCEPT_CLASS;
}
}, new ConstructorInterceptPoint() {
@Override
......@@ -51,14 +87,14 @@ public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorInterceptor4UriArg";
return CONSTRUCTOR_WITH_URI_ARG_INTERCEPT_CLASS;
}
}};
}
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {new InstanceMethodsInterceptPoint() {
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return not(ElementMatchers.<MethodDescription>isPrivate()
......
com.a.eye.skywalking.plugin.jedis.v2.define.JedisPluginDefine
com.a.eye.skywalking.plugin.jedis.v2.define.JedisClusterPluginDefine
com.a.eye.skywalking.plugin.jedis.v2.define.JedisClusterInstrumentation
com.a.eye.skywalking.plugin.jedis.v2.define.JedisInstrumentation
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册