Merge remote-tracking branch 'origin/master'
# Conflicts: # skywalking-storage-center/skywalking-storage/src/test/java/StorageThread.java
This commit is contained in:
commit
2f02f74dad
|
|
@ -12,9 +12,8 @@ SkyWalking: Large-Scale Distributed Systems Tracing Infrastructure, also known D
|
|||
|
||||
# Abstract
|
||||
* An open source Large-Scale Distributed Systems Tracing Infrastructure, also known a ditributed tracer.
|
||||
* Based on [Google Dapper Paper: Dapper, a Large-Scale Distributed Systems Tracing Infrastructure](http://research.google.com/pubs/pub36356.html), [Simplified Chines](http://duanple.blog.163.com/blog/static/70971767201329113141336/)
|
||||
* Supports popular rpc frameworks, such as [dubbo](https://github.com/alibaba/dubbo), [dubbox](https://github.com/dangdangdotcom/dubbox), [motan](https://github.com/weibocom/motan) etc., supports email-alert when application occurs unexpected exception。
|
||||
* Execution time of creating span than 100μs.
|
||||
* Based on [Google Dapper Paper: Dapper, a Large-Scale Distributed Systems Tracing Infrastructure](http://research.google.com/pubs/pub36356.html), [read Simplified Chinese Version](http://duanple.blog.163.com/blog/static/70971767201329113141336/)
|
||||
* Support popular rpc frameworks, such as [dubbo](https://github.com/alibaba/dubbo), [dubbox](https://github.com/dangdangdotcom/dubbox), [motan](https://github.com/weibocom/motan) etc., trigger email-alert when application occurs unexpected exception。
|
||||
* Easy to deploy, **even in product mode** (since 2.0) . No need of Hadoop, HBase, or Cassandra Cluster.
|
||||
* Pure Java server implements. provide gRPC (since 2.0) and HTTP (since 2.1) cross-platform spans collecting service.
|
||||
|
||||
|
|
|
|||
|
|
@ -26,17 +26,17 @@
|
|||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-netty</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-protobuf</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-stub</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
<configuration>
|
||||
<protocArtifact>com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}</protocArtifact>
|
||||
<pluginId>grpc-java</pluginId>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1:exe:${os.detected.classifier}</pluginArtifact>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.2:exe:${os.detected.classifier}</pluginArtifact>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ public class SpanStorageClient {
|
|||
StreamObserver<RequestSpan> requestSpanStreamObserver = spanStorageStub.storageRequestSpan(new StreamObserver<SendResult>() {
|
||||
@Override
|
||||
public void onNext(SendResult sendResult) {
|
||||
listener.onBatchFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -37,6 +36,7 @@ public class SpanStorageClient {
|
|||
|
||||
@Override
|
||||
public void onCompleted() {
|
||||
listener.onBatchFinished();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -51,7 +51,6 @@ public class SpanStorageClient {
|
|||
StreamObserver<AckSpan> ackSpanStreamObserver = spanStorageStub.storageACKSpan(new StreamObserver<SendResult>() {
|
||||
@Override
|
||||
public void onNext(SendResult sendResult) {
|
||||
listener.onBatchFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -61,6 +60,7 @@ public class SpanStorageClient {
|
|||
|
||||
@Override
|
||||
public void onCompleted() {
|
||||
listener.onBatchFinished();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.a.eye.skywalking.plugin.interceptor;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/29.
|
||||
*/
|
||||
public interface ConstructorInterceptPoint{
|
||||
/**
|
||||
*
|
||||
* @return represents a class name, the class instance must instanceof InstanceConstructorInterceptor.
|
||||
*/
|
||||
String getConstructorInterceptor();
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.a.eye.skywalking.plugin.interceptor;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/29.
|
||||
*/
|
||||
public interface InstanceMethodsInterceptPoint {
|
||||
/**
|
||||
* 返回需要被增强的方法列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MethodMatcher[] getMethodsMatchers();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return represents a class name, the class instance must instanceof InstanceMethodsAroundInterceptor.
|
||||
*/
|
||||
String getMethodsInterceptor();
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.a.eye.skywalking.plugin.interceptor;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/29.
|
||||
*/
|
||||
public interface StaticMethodsInterceptPoint {
|
||||
/**
|
||||
* 返回需要被增强的方法列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MethodMatcher[] getMethodsMatchers();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return represents a class name, the class instance must instanceof StaticMethodsAroundInterceptor.
|
||||
*/
|
||||
String getMethodsInterceptor();
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.a.eye.skywalking.plugin.interceptor.assist;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceConstructorInterceptor;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/29.
|
||||
*/
|
||||
public class DefaultConstructorInterceptor implements InstanceConstructorInterceptor {
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
// do nothing as default implements.
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ public class ClassConstructorInterceptor {
|
|||
@FieldProxy(ClassEnhancePluginDefine.contextAttrName) FieldSetter accessor,
|
||||
@AllArguments Object[] allArguments) {
|
||||
try {
|
||||
InstanceMethodsAroundInterceptor interceptor = InterceptorInstanceLoader
|
||||
InstanceConstructorInterceptor interceptor = InterceptorInstanceLoader
|
||||
.load(instanceMethodsAroundInterceptorClassName, obj.getClass().getClassLoader());
|
||||
|
||||
EnhancedClassInstanceContext context = new EnhancedClassInstanceContext();
|
||||
|
|
@ -34,7 +34,7 @@ public class ClassConstructorInterceptor {
|
|||
allArguments);
|
||||
interceptor.onConstruct(context, interceptorContext);
|
||||
} catch (Throwable t) {
|
||||
logger.error("ClassConstructorInterceptor failue.", t);
|
||||
logger.error("ClassConstructorInterceptor failure.", t);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.a.eye.skywalking.logging.api.ILog;
|
|||
import com.a.eye.skywalking.logging.api.LogManager;
|
||||
import com.a.eye.skywalking.plugin.AbstractClassEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.plugin.PluginException;
|
||||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.*;
|
||||
import com.a.eye.skywalking.util.StringUtil;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.dynamic.DynamicType;
|
||||
|
|
@ -18,9 +18,6 @@ import net.bytebuddy.implementation.bind.annotation.FieldProxy;
|
|||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.EnhanceException;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
|
||||
public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePluginDefine {
|
||||
private static ILog logger = LogManager.getLogger(ClassEnhancePluginDefine.class);
|
||||
|
||||
|
|
@ -36,8 +33,22 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
|
|||
}
|
||||
|
||||
private DynamicType.Builder<?> enhanceInstance(String enhanceOriginClassName, DynamicType.Builder<?> newClassBuilder) throws PluginException {
|
||||
MethodMatcher[] methodMatchers = getInstanceMethodsMatchers();
|
||||
if (methodMatchers == null) {
|
||||
ConstructorInterceptPoint constructorInterceptPoint = getConstructorsInterceptPoint();
|
||||
InstanceMethodsInterceptPoint[] instanceMethodsInterceptPoints = getInstanceMethodsInterceptPoints();
|
||||
|
||||
boolean existedConstructorInterceptPoint = false;
|
||||
if (constructorInterceptPoint != null) {
|
||||
existedConstructorInterceptPoint = true;
|
||||
}
|
||||
boolean existedMethodsInterceptPoints = false;
|
||||
if (instanceMethodsInterceptPoints != null && instanceMethodsInterceptPoints.length > 0) {
|
||||
existedMethodsInterceptPoints = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* nothing need to be enhanced in class instance, maybe need enhance static methods.
|
||||
*/
|
||||
if (!existedConstructorInterceptPoint && !existedMethodsInterceptPoints) {
|
||||
return newClassBuilder;
|
||||
}
|
||||
|
||||
|
|
@ -49,99 +60,104 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
|
|||
* 1.add field '_$EnhancedClassInstanceContext' of type
|
||||
* EnhancedClassInstanceContext <br/>
|
||||
*
|
||||
* 2.intercept constructor by default, and intercept method which it's
|
||||
* required by interceptorDefineClass. <br/>
|
||||
*/
|
||||
String interceptor = getInstanceMethodsInterceptor();
|
||||
if (StringUtil.isEmpty(interceptor)) {
|
||||
throw new EnhanceException("no InstanceMethodsAroundInterceptor define. ");
|
||||
String constructorInterceptor;
|
||||
if (existedConstructorInterceptPoint) {
|
||||
constructorInterceptor = constructorInterceptPoint.getConstructorInterceptor();
|
||||
} else {
|
||||
constructorInterceptor = "com.a.eye.skywalking.plugin.interceptor.assist.DefaultConstructorInterceptor";
|
||||
}
|
||||
|
||||
newClassBuilder = newClassBuilder.defineField(contextAttrName, EnhancedClassInstanceContext.class, ACC_PRIVATE).constructor(any()).intercept(SuperMethodCall.INSTANCE
|
||||
.andThen(MethodDelegation.to(new ClassConstructorInterceptor(interceptor)).appendParameterBinder(FieldProxy.Binder.install(FieldGetter.class, FieldSetter.class))));
|
||||
.andThen(MethodDelegation.to(new ClassConstructorInterceptor(constructorInterceptor)).appendParameterBinder(FieldProxy.Binder.install(FieldGetter.class, FieldSetter.class))));
|
||||
|
||||
ClassInstanceMethodsInterceptor classMethodInterceptor = new ClassInstanceMethodsInterceptor(interceptor);
|
||||
if(existedMethodsInterceptPoints) {
|
||||
for (InstanceMethodsInterceptPoint instanceMethodsInterceptPoint : instanceMethodsInterceptPoints) {
|
||||
|
||||
StringBuilder enhanceRules = new StringBuilder("\nprepare to enhance class [" + enhanceOriginClassName + "] instance methods as following rules:\n");
|
||||
int ruleIdx = 1;
|
||||
for (MethodMatcher methodMatcher : methodMatchers) {
|
||||
enhanceRules.append("\t" + ruleIdx++ + ". " + methodMatcher + "\n");
|
||||
}
|
||||
logger.debug(enhanceRules.toString());
|
||||
ElementMatcher.Junction<MethodDescription> matcher = null;
|
||||
for (MethodMatcher methodMatcher : methodMatchers) {
|
||||
logger.debug("enhance class {} instance methods by rule: {}", enhanceOriginClassName, methodMatcher);
|
||||
if (matcher == null) {
|
||||
matcher = methodMatcher.buildMatcher();
|
||||
continue;
|
||||
String interceptor = instanceMethodsInterceptPoint.getMethodsInterceptor();
|
||||
if (StringUtil.isEmpty(interceptor)) {
|
||||
throw new EnhanceException("no InstanceMethodsAroundInterceptor define. ");
|
||||
}
|
||||
ClassInstanceMethodsInterceptor classMethodInterceptor = new ClassInstanceMethodsInterceptor(interceptor);
|
||||
|
||||
MethodMatcher[] methodMatchers = instanceMethodsInterceptPoint.getMethodsMatchers();
|
||||
|
||||
StringBuilder enhanceRules = new StringBuilder("\nprepare to enhance class [" + enhanceOriginClassName + "] instance methods as following rules:\n");
|
||||
int ruleIdx = 1;
|
||||
for (MethodMatcher methodMatcher : methodMatchers) {
|
||||
enhanceRules.append("\t" + ruleIdx++ + ". " + methodMatcher + "\n");
|
||||
}
|
||||
logger.debug(enhanceRules.toString());
|
||||
ElementMatcher.Junction<MethodDescription> matcher = null;
|
||||
for (MethodMatcher methodMatcher : methodMatchers) {
|
||||
logger.debug("enhance class {} instance methods by rule: {}", enhanceOriginClassName, methodMatcher);
|
||||
if (matcher == null) {
|
||||
matcher = methodMatcher.buildMatcher();
|
||||
continue;
|
||||
}
|
||||
|
||||
matcher = matcher.or(methodMatcher.buildMatcher());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* exclude static methods.
|
||||
*/
|
||||
matcher = matcher.and(not(ElementMatchers.isStatic()));
|
||||
newClassBuilder = newClassBuilder.method(matcher).intercept(MethodDelegation.to(classMethodInterceptor));
|
||||
}
|
||||
|
||||
matcher = matcher.or(methodMatcher.buildMatcher());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* exclude static methods.
|
||||
*/
|
||||
matcher = matcher.and(not(ElementMatchers.isStatic()));
|
||||
newClassBuilder = newClassBuilder.method(matcher).intercept(MethodDelegation.to(classMethodInterceptor));
|
||||
|
||||
return newClassBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回需要被增强的方法列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract MethodMatcher[] getInstanceMethodsMatchers();
|
||||
protected abstract ConstructorInterceptPoint getConstructorsInterceptPoint();
|
||||
|
||||
protected abstract InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints();
|
||||
|
||||
/**
|
||||
* 返回增强拦截器的实现<br/>
|
||||
* 每个拦截器在同一个被增强类的内部,保持单例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract String getInstanceMethodsInterceptor();
|
||||
|
||||
private DynamicType.Builder<?> enhanceClass(String enhanceOriginClassName, DynamicType.Builder<?> newClassBuilder) throws PluginException {
|
||||
MethodMatcher[] methodMatchers = getStaticMethodsMatchers();
|
||||
if (methodMatchers == null) {
|
||||
StaticMethodsInterceptPoint[] staticMethodsInterceptPoints = getStaticMethodsInterceptPoints();
|
||||
|
||||
if(staticMethodsInterceptPoints == null || staticMethodsInterceptPoints.length == 0){
|
||||
return newClassBuilder;
|
||||
}
|
||||
|
||||
String interceptor = getStaticMethodsInterceptor();
|
||||
if (StringUtil.isEmpty(interceptor)) {
|
||||
throw new EnhanceException("no StaticMethodsAroundInterceptor define. ");
|
||||
}
|
||||
for (StaticMethodsInterceptPoint staticMethodsInterceptPoint : staticMethodsInterceptPoints) {
|
||||
MethodMatcher[] methodMatchers = staticMethodsInterceptPoint.getMethodsMatchers();
|
||||
|
||||
|
||||
ClassStaticMethodsInterceptor classMethodInterceptor = new ClassStaticMethodsInterceptor(interceptor);
|
||||
|
||||
StringBuilder enhanceRules = new StringBuilder("\nprepare to enhance class [" + enhanceOriginClassName + "] static methods as following rules:\n");
|
||||
int ruleIdx = 1;
|
||||
for (MethodMatcher methodMatcher : methodMatchers) {
|
||||
enhanceRules.append("\t" + ruleIdx++ + ". " + methodMatcher + "\n");
|
||||
}
|
||||
logger.debug(enhanceRules.toString());
|
||||
ElementMatcher.Junction<MethodDescription> matcher = null;
|
||||
for (MethodMatcher methodMatcher : methodMatchers) {
|
||||
logger.debug("enhance class {} static methods by rule: {}", enhanceOriginClassName, methodMatcher);
|
||||
if (matcher == null) {
|
||||
matcher = methodMatcher.buildMatcher();
|
||||
continue;
|
||||
String interceptor = staticMethodsInterceptPoint.getMethodsInterceptor();
|
||||
if (StringUtil.isEmpty(interceptor)) {
|
||||
throw new EnhanceException("no StaticMethodsAroundInterceptor define. ");
|
||||
}
|
||||
|
||||
matcher = matcher.or(methodMatcher.buildMatcher());
|
||||
ClassStaticMethodsInterceptor classMethodInterceptor = new ClassStaticMethodsInterceptor(interceptor);
|
||||
|
||||
StringBuilder enhanceRules = new StringBuilder("\nprepare to enhance class [" + enhanceOriginClassName + "] static methods as following rules:\n");
|
||||
int ruleIdx = 1;
|
||||
for (MethodMatcher methodMatcher : methodMatchers) {
|
||||
enhanceRules.append("\t" + ruleIdx++ + ". " + methodMatcher + "\n");
|
||||
}
|
||||
logger.debug(enhanceRules.toString());
|
||||
ElementMatcher.Junction<MethodDescription> matcher = null;
|
||||
for (MethodMatcher methodMatcher : methodMatchers) {
|
||||
logger.debug("enhance class {} static methods by rule: {}", enhanceOriginClassName, methodMatcher);
|
||||
if (matcher == null) {
|
||||
matcher = methodMatcher.buildMatcher();
|
||||
continue;
|
||||
}
|
||||
|
||||
matcher = matcher.or(methodMatcher.buildMatcher());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* restrict static methods.
|
||||
*/
|
||||
matcher = matcher.and(ElementMatchers.isStatic());
|
||||
newClassBuilder = newClassBuilder.method(matcher).intercept(MethodDelegation.to(classMethodInterceptor));
|
||||
}
|
||||
|
||||
/**
|
||||
* restrict static methods.
|
||||
*/
|
||||
matcher = matcher.and(ElementMatchers.isStatic());
|
||||
newClassBuilder = newClassBuilder.method(matcher).intercept(MethodDelegation.to(classMethodInterceptor));
|
||||
|
||||
return newClassBuilder;
|
||||
}
|
||||
|
||||
|
|
@ -150,13 +166,5 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract MethodMatcher[] getStaticMethodsMatchers();
|
||||
|
||||
/**
|
||||
* 返回增强拦截器的实现<br/>
|
||||
* 每个拦截器在同一个被增强类的内部,保持单例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract String getStaticMethodsInterceptor();
|
||||
protected abstract StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.StaticMethodsInterceptPoint;
|
||||
|
||||
/**
|
||||
* 仅增强拦截实例方法
|
||||
|
|
@ -12,12 +12,7 @@ public abstract class ClassInstanceMethodsEnhancePluginDefine extends
|
|||
ClassEnhancePluginDefine {
|
||||
|
||||
@Override
|
||||
protected MethodMatcher[] getStaticMethodsMatchers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getStaticMethodsInterceptor() {
|
||||
protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints(){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.a.eye.skywalking.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
|
||||
/**
|
||||
* 仅增强拦截类级别静态方法
|
||||
|
|
@ -12,12 +13,12 @@ public abstract class ClassStaticMethodsEnhancePluginDefine extends
|
|||
ClassEnhancePluginDefine {
|
||||
|
||||
@Override
|
||||
protected MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInstanceMethodsInterceptor() {
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package com.a.eye.skywalking.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/29.
|
||||
*/
|
||||
public interface InstanceConstructorInterceptor {
|
||||
void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext);
|
||||
}
|
||||
|
|
@ -3,11 +3,9 @@ package com.a.eye.skywalking.plugin.interceptor.enhance;
|
|||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
|
||||
public interface InstanceMethodsAroundInterceptor {
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext);
|
||||
void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result);
|
||||
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result);
|
||||
Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret);
|
||||
|
||||
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret);
|
||||
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext);
|
||||
void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
package com.a.eye.skywalking.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.api.IBuriedPointType;
|
||||
import net.bytebuddy.implementation.bind.annotation.AllArguments;
|
||||
import net.bytebuddy.implementation.bind.annotation.Origin;
|
||||
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
|
||||
import net.bytebuddy.implementation.bind.annotation.SuperCall;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class MethodInputAndOutParameterInterceptor {
|
||||
|
||||
public static IBuriedPointType METHOD_INVOKE_BURIEDPOINT = new IBuriedPointType() {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "LOCAL";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallType getCallType() {
|
||||
return CallType.SYNC;
|
||||
}
|
||||
};
|
||||
|
||||
@RuntimeType
|
||||
public Object interceptor(@AllArguments Object[] allArgument, @Origin Method method, @Origin Class<?> clazz,
|
||||
@SuperCall Callable<?> zuper) throws Exception {
|
||||
|
||||
|
||||
|
||||
Object ret = null;
|
||||
try {
|
||||
ret = zuper.call();
|
||||
} catch (Throwable e) {
|
||||
throw e;
|
||||
} finally {
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@ package com.a.eye.skywalking.plugin.interceptor.enhance;
|
|||
|
||||
|
||||
public interface StaticMethodsAroundInterceptor {
|
||||
public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result);
|
||||
void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result);
|
||||
|
||||
public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret);
|
||||
Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret);
|
||||
|
||||
public void handleMethodException(Throwable t, MethodInvokeContext interceptorContext);
|
||||
void handleMethodException(Throwable t, MethodInvokeContext interceptorContext);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,6 @@ import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
|||
* Created by xin on 16-6-8.
|
||||
*/
|
||||
public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
System.out.println("before method");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package test.a.eye.cloud.matcher;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.PrivateMethodMatcher;
|
||||
|
|
@ -10,24 +12,34 @@ import com.a.eye.skywalking.plugin.interceptor.matcher.PrivateMethodMatcher;
|
|||
public class TestMatcherDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
@Override
|
||||
public String enhanceClassName() {
|
||||
return "TestMatcherClass";
|
||||
return "test.a.eye.cloud.matcher.TestMatcherClass";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
// return new MethodMatcher[]{
|
||||
// new PrivateMethodMatcher(),
|
||||
// new MethodsExclusiveMatcher(new SimpleMethodMatcher("set")),
|
||||
// new SimpleMethodMatcher(MethodMatcher.Modifier.Private, "set", 1)
|
||||
// };
|
||||
// return new MethodMatcher[] { new SimpleMethodMatcher(Modifier.Public, "printabc", new Class[]{String.class, String.class}) };
|
||||
return new MethodMatcher[] { new PrivateMethodMatcher()};
|
||||
//return new MethodMatcher[]{new AnyMethodsMatcher()};
|
||||
//return new MethodMatcher[]{new MethodsExclusiveMatcher(new SimpleMethodMatcher("set"), new SimpleMethodMatcher(MethodMatcher.Modifier.Public,"get"))};
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInstanceMethodsInterceptor() {
|
||||
return "TestMatcherDefine";
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[] {new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
// return new MethodMatcher[]{
|
||||
// new PrivateMethodMatcher(),
|
||||
// new MethodsExclusiveMatcher(new SimpleMethodMatcher("set")),
|
||||
// new SimpleMethodMatcher(MethodMatcher.Modifier.Private, "set", 1)
|
||||
// };
|
||||
// return new MethodMatcher[] { new SimpleMethodMatcher(Modifier.Public, "printabc", new Class[]{String.class, String.class}) };
|
||||
return new MethodMatcher[] {new PrivateMethodMatcher()};
|
||||
//return new MethodMatcher[]{new AnyMethodsMatcher()};
|
||||
//return new MethodMatcher[]{new MethodsExclusiveMatcher(new SimpleMethodMatcher("set"), new SimpleMethodMatcher(MethodMatcher.Modifier.Public,"get"))};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "test.a.eye.cloud.matcher.TestAroundInterceptor";
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,34 @@
|
|||
package com.a.eye.skywalking.plugin.dubbo;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
|
||||
public class DubboPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
@Override
|
||||
protected MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("invoke")};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.dubbo.MonitorFilterInterceptor";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String enhanceClassName() {
|
||||
return "com.alibaba.dubbo.monitor.support.MonitorFilter";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("invoke")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.dubbo.MonitorFilterInterceptor";
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,6 @@ import com.alibaba.dubbo.rpc.Result;
|
|||
import com.alibaba.dubbo.rpc.RpcContext;
|
||||
|
||||
public class MonitorFilterInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext,
|
||||
MethodInterceptResult result) {
|
||||
|
|
|
|||
|
|
@ -19,11 +19,6 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
|
|||
|
||||
private static RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context,
|
||||
ConstructorInvokeContext interceptorContext) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context,
|
||||
InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.httpClient.v4.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
|
||||
|
|
@ -17,8 +18,18 @@ public class AbstractHttpClientPluginDefine extends HttpClientPluginDefine {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[] {
|
||||
new SimpleMethodMatcher("doExecute")};
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[] {
|
||||
new SimpleMethodMatcher("doExecute")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return getInstanceMethodsInterceptor();
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.httpClient.v4.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
||||
|
|
@ -15,9 +16,18 @@ public class DefaultRequestDirectorPluginDefine extends HttpClientPluginDefine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[] {
|
||||
new SimpleMethodMatcher("execute")};
|
||||
}
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[] {
|
||||
new SimpleMethodMatcher("execute")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return getInstanceMethodsInterceptor();
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
package com.a.eye.skywalking.plugin.httpClient.v4.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
|
||||
public abstract class HttpClientPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
@Override
|
||||
public String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.httpClient.v4.HttpClientExecuteInterceptor";
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.httpClient.v4.HttpClientExecuteInterceptor";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,27 @@
|
|||
package com.a.eye.skywalking.plugin.httpClient.v4.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
||||
public class InternalHttpClientPluginDefine extends HttpClientPluginDefine {
|
||||
@Override
|
||||
public MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("doExecute")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String enhanceClassName() {
|
||||
return "org.apache.http.impl.client.InternalHttpClient";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("doExecute")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return getInstanceMethodsInterceptor();
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,27 @@
|
|||
package com.a.eye.skywalking.plugin.httpClient.v4.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
||||
public class MinimalHttpClientPluginDefine extends HttpClientPluginDefine {
|
||||
@Override
|
||||
public MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("doExecute")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String enhanceClassName() {
|
||||
return "org.apache.http.impl.client.MinimalHttpClient";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("doExecute")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return getInstanceMethodsInterceptor();
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,29 @@
|
|||
package com.a.eye.skywalking.plugin.jdbc.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
|
||||
public abstract class AbstractDatabasePluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
@Override
|
||||
protected MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("connect")};
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.jdbc.define.JDBCDriverInterceptor";
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("connect")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.jdbc.define.JDBCDriverInterceptor";
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ import java.sql.Connection;
|
|||
import java.util.Properties;
|
||||
|
||||
public class JDBCDriverInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext,
|
||||
MethodInterceptResult result) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.a.eye.skywalking.plugin.jedis.v2;
|
|||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceConstructorInterceptor;
|
||||
import redis.clients.jedis.HostAndPort;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -10,7 +11,7 @@ import java.util.Set;
|
|||
/**
|
||||
* Created by xin on 16-6-12.
|
||||
*/
|
||||
public class JedisClusterInterceptor extends JedisBaseInterceptor {
|
||||
public class JedisClusterInterceptor extends JedisBaseInterceptor implements InstanceConstructorInterceptor {
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
StringBuilder redisConnInfo = new StringBuilder();
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceConstructorInterceptor;
|
||||
import redis.clients.jedis.JedisShardInfo;
|
||||
|
||||
public class JedisInterceptor extends JedisBaseInterceptor {
|
||||
import java.net.URI;
|
||||
|
||||
public class JedisInterceptor extends JedisBaseInterceptor implements InstanceConstructorInterceptor {
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.AnyMethodsMatcher;
|
||||
|
|
@ -12,14 +14,30 @@ public class JedisClusterPluginDefine extends ClassInstanceMethodsEnhancePluginD
|
|||
}
|
||||
|
||||
@Override
|
||||
public MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[]{
|
||||
new AnyMethodsMatcher()
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return new ConstructorInterceptPoint(){
|
||||
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterInterceptor";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterInterceptor";
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[]{
|
||||
new AnyMethodsMatcher()
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterInterceptor";
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.MethodsExclusiveMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
|
|
@ -14,24 +16,38 @@ public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[]{
|
||||
new MethodsExclusiveMatcher(
|
||||
new PrivateMethodMatcher(),
|
||||
new SimpleMethodMatcher("close"),
|
||||
new SimpleMethodMatcher("getDB"),
|
||||
new SimpleMethodMatcher("connect"),
|
||||
new SimpleMethodMatcher("setDataSource"),
|
||||
new SimpleMethodMatcher("resetState"),
|
||||
new SimpleMethodMatcher("clusterSlots"),
|
||||
new SimpleMethodMatcher("checkIsInMultiOrPipeline")
|
||||
)
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return new ConstructorInterceptPoint() {
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.jedis.v2.JedisInterceptor";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.jedis.v2.JedisInterceptor";
|
||||
}
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[]{
|
||||
new MethodsExclusiveMatcher(
|
||||
new PrivateMethodMatcher(),
|
||||
new SimpleMethodMatcher("close"),
|
||||
new SimpleMethodMatcher("getDB"),
|
||||
new SimpleMethodMatcher("connect"),
|
||||
new SimpleMethodMatcher("setDataSource"),
|
||||
new SimpleMethodMatcher("resetState"),
|
||||
new SimpleMethodMatcher("clusterSlots"),
|
||||
new SimpleMethodMatcher("checkIsInMultiOrPipeline")
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.jedis.v2.JedisInterceptor";
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,7 @@ package com.a.eye.skywalking.plugin.motan;
|
|||
import com.a.eye.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.a.eye.skywalking.model.ContextData;
|
||||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.*;
|
||||
import com.weibo.api.motan.rpc.Request;
|
||||
import com.weibo.api.motan.rpc.URL;
|
||||
|
||||
|
|
@ -15,7 +12,7 @@ import static com.a.eye.skywalking.plugin.motan.IdentificationUtil.generateIdent
|
|||
/**
|
||||
* Motan client interceptor
|
||||
*/
|
||||
public class MotanClientInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
public class MotanClientInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
context.set("serviceURI", interceptorContext.allArguments()[1]);
|
||||
|
|
|
|||
|
|
@ -3,14 +3,11 @@ package com.a.eye.skywalking.plugin.motan;
|
|||
import com.a.eye.skywalking.invoke.monitor.RPCServerInvokeMonitor;
|
||||
import com.a.eye.skywalking.model.ContextData;
|
||||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.*;
|
||||
import com.weibo.api.motan.rpc.Request;
|
||||
import com.weibo.api.motan.rpc.URL;
|
||||
|
||||
public class MotanServerInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
public class MotanServerInterceptor implements InstanceConstructorInterceptor, InstanceMethodsAroundInterceptor {
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
context.set("serviceURI", interceptorContext.allArguments()[0]);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.a.eye.skywalking.plugin.motan.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
|
@ -11,12 +13,29 @@ public class MotanClientDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[] {new SimpleMethodMatcher("call")};
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return new ConstructorInterceptPoint() {
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.motan.MotanClientInterceptor";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.motan.MotanClientInterceptor";
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{
|
||||
new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[] {new SimpleMethodMatcher("call")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.motan.MotanClientInterceptor";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.a.eye.skywalking.plugin.motan.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
|
@ -12,12 +14,27 @@ public class MotanServerDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
return new MethodMatcher[] {new SimpleMethodMatcher("call")};
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return new ConstructorInterceptPoint() {
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.motan.MotanServerInterceptor";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.motan.MotanServerInterceptor";
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[] {new SimpleMethodMatcher("call")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.motan.MotanServerInterceptor";
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,6 @@ public class TomcatPluginInterceptor implements InstanceMethodsAroundInterceptor
|
|||
private static final String DEFAULT_TRACE_NAME = "SkyWalking-TRACING-NAME";
|
||||
private static final String TRACE_ID_HEADER_NAME = "SW-TraceId";
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
//DO Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
Object[] args = interceptorContext.allArguments();
|
||||
|
|
|
|||
|
|
@ -1,23 +1,34 @@
|
|||
package com.a.eye.skywalking.plugin.tomcat78x.define;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
||||
public class TomcatPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
@Override
|
||||
protected MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("invoke")};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInstanceMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.tomcat78x.TomcatPluginInterceptor";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String enhanceClassName() {
|
||||
return "org.apache.catalina.core.StandardEngineValve";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("invoke")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.plugin.tomcat78x.TomcatPluginInterceptor";
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,16 +13,6 @@ public class Config {
|
|||
}
|
||||
|
||||
|
||||
public static class DataConsumer {
|
||||
|
||||
public static int CHANNEL_SIZE = 10;
|
||||
|
||||
public static int BUFFER_SIZE = 1000;
|
||||
|
||||
public static int CONSUMER_SIZE = 5;
|
||||
}
|
||||
|
||||
|
||||
public static class DataFile {
|
||||
public static String PATH = "/data/file";
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,14 @@ public class DataFileWriter {
|
|||
}
|
||||
|
||||
IndexMetaCollection collections = new IndexMetaCollection();
|
||||
for (SpanData data : spanData) {
|
||||
collections.add(dataFile.write(data));
|
||||
try {
|
||||
for (SpanData data : spanData) {
|
||||
collections.add(dataFile.write(data));
|
||||
}
|
||||
}finally {
|
||||
dataFile.flush();
|
||||
}
|
||||
|
||||
dataFile.flush();
|
||||
|
||||
return collections;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.a.eye.skywalking.storage.data.file;
|
||||
|
||||
import com.a.eye.skywalking.network.grpc.RequestSpan;
|
||||
import com.a.eye.skywalking.storage.data.index.IndexMetaInfo;
|
||||
import com.a.eye.skywalking.storage.data.spandata.RequestSpanData;
|
||||
import com.a.eye.skywalking.storage.data.spandata.SpanDataBuilder;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/29.
|
||||
*/
|
||||
public class DataFileTest {
|
||||
@Test
|
||||
public void testWriteFile(){
|
||||
DataFile dataFile = new DataFile();
|
||||
|
||||
IndexMetaInfo info = null;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
RequestSpan span = RequestSpan.newBuilder().setUserId("1").setApplicationId("app").build();
|
||||
|
||||
try {
|
||||
info = dataFile.write(new RequestSpanData(span));
|
||||
} finally {
|
||||
dataFile.flush();
|
||||
}
|
||||
|
||||
RequestSpan newSpan = SpanDataBuilder.buildRequestSpan(dataFile.read(info.getOffset(), info.getLength()));
|
||||
|
||||
Assert.assertEquals("1", newSpan.getUserId());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue