diff --git a/README.md b/README.md
index a78cac44ca83cf61be3cbc06c31bc3d561bb1a17..774dcaecd10f13bd8753acfa8407a38a970b99cd 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/skywalking-network/pom.xml b/skywalking-network/pom.xml
index 69f74e99803a6330af91f8ad75d11e61056effb2..3ba73a507164c73a3aa7f784a465cb62db746bf1 100644
--- a/skywalking-network/pom.xml
+++ b/skywalking-network/pom.xml
@@ -26,17 +26,17 @@
io.grpc
grpc-netty
- 1.0.1
+ 1.0.2
io.grpc
grpc-protobuf
- 1.0.1
+ 1.0.2
io.grpc
grpc-stub
- 1.0.1
+ 1.0.2
@@ -56,7 +56,7 @@
com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}
grpc-java
- io.grpc:protoc-gen-grpc-java:1.0.1:exe:${os.detected.classifier}
+ io.grpc:protoc-gen-grpc-java:1.0.2:exe:${os.detected.classifier}
diff --git a/skywalking-network/src/main/java/com/a/eye/skywalking/network/grpc/client/SpanStorageClient.java b/skywalking-network/src/main/java/com/a/eye/skywalking/network/grpc/client/SpanStorageClient.java
index 1bd135d11916b37ddc7baeb4ff1e91a76074cb52..2779083f096709ae3fbbefb091f56d4f38edc42d 100644
--- a/skywalking-network/src/main/java/com/a/eye/skywalking/network/grpc/client/SpanStorageClient.java
+++ b/skywalking-network/src/main/java/com/a/eye/skywalking/network/grpc/client/SpanStorageClient.java
@@ -27,7 +27,6 @@ public class SpanStorageClient {
StreamObserver requestSpanStreamObserver = spanStorageStub.storageRequestSpan(new StreamObserver() {
@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 ackSpanStreamObserver = spanStorageStub.storageACKSpan(new StreamObserver() {
@Override
public void onNext(SendResult sendResult) {
- listener.onBatchFinished();
}
@Override
@@ -61,6 +60,7 @@ public class SpanStorageClient {
@Override
public void onCompleted() {
+ listener.onBatchFinished();
}
});
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/ConstructorInterceptPoint.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/ConstructorInterceptPoint.java
new file mode 100644
index 0000000000000000000000000000000000000000..69f952d5bb29554c0aecc111030ce74132b1b587
--- /dev/null
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/ConstructorInterceptPoint.java
@@ -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();
+}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/InstanceMethodsInterceptPoint.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/InstanceMethodsInterceptPoint.java
new file mode 100644
index 0000000000000000000000000000000000000000..48e1609f5107db1b8142b53dee104b51bf6dc82c
--- /dev/null
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/InstanceMethodsInterceptPoint.java
@@ -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();
+}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/StaticMethodsInterceptPoint.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/StaticMethodsInterceptPoint.java
new file mode 100644
index 0000000000000000000000000000000000000000..e7b46d39e1365445cf2d5e752c0d746ff3cef307
--- /dev/null
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/StaticMethodsInterceptPoint.java
@@ -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();
+}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/assist/DefaultConstructorInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/assist/DefaultConstructorInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..dd7e1876c77e7de751582d47e2f91961f44c2ce8
--- /dev/null
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/assist/DefaultConstructorInterceptor.java
@@ -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.
+ }
+}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassConstructorInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassConstructorInterceptor.java
index 73f0552bb32b95f285e89359998745e6e200123c..304b1b8baa394889b9301b5468ce474ff176b39a 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassConstructorInterceptor.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassConstructorInterceptor.java
@@ -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);
}
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassEnhancePluginDefine.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
index d7ccaf5368fe898a262f5dbdc527b0b819e0b896..500c69d5c2d24d67733ac924943e5e7b2a3e8f7d 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
@@ -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,98 +60,103 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
* 1.add field '_$EnhancedClassInstanceContext' of type
* EnhancedClassInstanceContext
*
- * 2.intercept constructor by default, and intercept method which it's
- * required by interceptorDefineClass.
*/
- 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))));
-
- ClassInstanceMethodsInterceptor classMethodInterceptor = new ClassInstanceMethodsInterceptor(interceptor);
-
- 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 matcher = null;
- for (MethodMatcher methodMatcher : methodMatchers) {
- logger.debug("enhance class {} instance methods by rule: {}", enhanceOriginClassName, methodMatcher);
- if (matcher == null) {
- matcher = methodMatcher.buildMatcher();
- continue;
+ .andThen(MethodDelegation.to(new ClassConstructorInterceptor(constructorInterceptor)).appendParameterBinder(FieldProxy.Binder.install(FieldGetter.class, FieldSetter.class))));
+
+ if(existedMethodsInterceptPoints) {
+ for (InstanceMethodsInterceptPoint instanceMethodsInterceptPoint : instanceMethodsInterceptPoints) {
+
+ 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 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();
- /**
- * 返回增强拦截器的实现
- * 每个拦截器在同一个被增强类的内部,保持单例
- *
- * @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();
+ String interceptor = staticMethodsInterceptPoint.getMethodsInterceptor();
+ if (StringUtil.isEmpty(interceptor)) {
+ throw new EnhanceException("no StaticMethodsAroundInterceptor define. ");
+ }
- ClassStaticMethodsInterceptor classMethodInterceptor = new ClassStaticMethodsInterceptor(interceptor);
+ 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 matcher = null;
- for (MethodMatcher methodMatcher : methodMatchers) {
- logger.debug("enhance class {} static methods by rule: {}", enhanceOriginClassName, methodMatcher);
- if (matcher == null) {
- matcher = methodMatcher.buildMatcher();
- continue;
+ 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 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());
+ 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();
-
- /**
- * 返回增强拦截器的实现
- * 每个拦截器在同一个被增强类的内部,保持单例
- *
- * @return
- */
- protected abstract String getStaticMethodsInterceptor();
+ protected abstract StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints();
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsEnhancePluginDefine.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsEnhancePluginDefine.java
index cd4136a397a4751e22772c908319bf042e7e3db4..f59a6cff1fb9889f01e3a18352ae86e755bfbbf2 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsEnhancePluginDefine.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsEnhancePluginDefine.java
@@ -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;
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassStaticMethodsEnhancePluginDefine.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassStaticMethodsEnhancePluginDefine.java
index 0f399161c63d63cfd7527e88be762064ed1868d8..dbabc00c30f08964ae3c508c81030509e4f59c37 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassStaticMethodsEnhancePluginDefine.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/ClassStaticMethodsEnhancePluginDefine.java
@@ -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;
}
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/InstanceConstructorInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/InstanceConstructorInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..ae7a551c22c37f5b62843c4fb79fd678da376806
--- /dev/null
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/InstanceConstructorInterceptor.java
@@ -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);
+}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/InstanceMethodsAroundInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/InstanceMethodsAroundInterceptor.java
index ecc1cd5225abd5fc80ce33b1dc113f76f479f908..31c697d7defac8570d714e97416a90c239f3b102 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/InstanceMethodsAroundInterceptor.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/InstanceMethodsAroundInterceptor.java
@@ -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);
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/MethodInputAndOutParameterInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/MethodInputAndOutParameterInterceptor.java
deleted file mode 100644
index 56e13fe430bd6d0da94bdccf939d5be71affe64d..0000000000000000000000000000000000000000
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/MethodInputAndOutParameterInterceptor.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java
index 6c81abb263f54b8a4b116c514771db84c1ae823d..b73b58f8fe9f4c81a0cbb40422d18546e7896c69 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java
@@ -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);
}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/test/a/eye/cloud/matcher/TestAroundInterceptor.java b/skywalking-sniffer/skywalking-api/src/test/java/test/a/eye/cloud/matcher/TestAroundInterceptor.java
index 9da50639f95c8a39a5e6e659aefe134b0282a297..065e4d0cb99770504ebbecf4f791b97c6a56f025 100644
--- a/skywalking-sniffer/skywalking-api/src/test/java/test/a/eye/cloud/matcher/TestAroundInterceptor.java
+++ b/skywalking-sniffer/skywalking-api/src/test/java/test/a/eye/cloud/matcher/TestAroundInterceptor.java
@@ -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");
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/test/a/eye/cloud/matcher/TestMatcherDefine.java b/skywalking-sniffer/skywalking-api/src/test/java/test/a/eye/cloud/matcher/TestMatcherDefine.java
index 0c4875e0ec08c01ccfc3f8dd6e888a1cca48a097..01368d7ab75faae40b4e28a4288bf11d1622564c 100644
--- a/skywalking-sniffer/skywalking-api/src/test/java/test/a/eye/cloud/matcher/TestMatcherDefine.java
+++ b/skywalking-sniffer/skywalking-api/src/test/java/test/a/eye/cloud/matcher/TestMatcherDefine.java
@@ -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";
+ }
+ }};
}
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboPluginDefine.java
index e51d4dbc1a8b53039bdc862ef8a2399e69551098..ff888c8966a5a2ce58b08781e8bc286b7cdb6f00 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboPluginDefine.java
@@ -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")};
+ protected String enhanceClassName() {
+ return "com.alibaba.dubbo.monitor.support.MonitorFilter";
}
@Override
- protected String getInstanceMethodsInterceptor() {
- return "com.a.eye.skywalking.plugin.dubbo.MonitorFilterInterceptor";
+ protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
+ return null;
}
@Override
- protected String enhanceClassName() {
- return "com.alibaba.dubbo.monitor.support.MonitorFilter";
+ 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";
+ }
+ }};
}
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/MonitorFilterInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/MonitorFilterInterceptor.java
index eb3e3cc6c62d309b5cad4b3bad892250cc71daf7..371a944fc10a145a47d594bf03c3d315100351f0 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/MonitorFilterInterceptor.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/MonitorFilterInterceptor.java
@@ -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) {
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
index 84d406cb72e9bd10e992e80cb7c42e4868232767..064310813c162bfeaafdd1dbe95d04a10e757158 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
@@ -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) {
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/AbstractHttpClientPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/AbstractHttpClientPluginDefine.java
index 83a3f04d3c79654d923b1c0566030281e6c87359..7b0ccfa9ff71e51edd954c87c674fff3daabb5df 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/AbstractHttpClientPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/AbstractHttpClientPluginDefine.java
@@ -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();
+ }
+ }};
}
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/DefaultRequestDirectorPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/DefaultRequestDirectorPluginDefine.java
index 9c92b8003d569681a56921e673dd12d34e1b2458..e953369f0e5773acbc77936cab479c464531a1d5 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/DefaultRequestDirectorPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/DefaultRequestDirectorPluginDefine.java
@@ -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();
+ }
+ }};
+ }
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/HttpClientPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/HttpClientPluginDefine.java
index 2ebe70fb802d299a6e09b9d59b0e0b88989ff0ea..6a50a46d5b714672e884fc49dd06be1034f0641f 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/HttpClientPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/HttpClientPluginDefine.java
@@ -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";
+ }
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/InternalHttpClientPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/InternalHttpClientPluginDefine.java
index ed067b05fc25547dc4360387ae740580eafa4422..c70fe50789111f8e99383e0164ae0ce4bb0942a8 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/InternalHttpClientPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/InternalHttpClientPluginDefine.java
@@ -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();
+ }
+ }};
+ }
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/MinimalHttpClientPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/MinimalHttpClientPluginDefine.java
index 71f92869daf6ee6dd5a0170788fecc40e35644ae..379dc675c4a3f24a09c74feb78d1f3555cda6dfb 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/MinimalHttpClientPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/MinimalHttpClientPluginDefine.java
@@ -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();
+ }
+ }};
+ }
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/AbstractDatabasePluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/AbstractDatabasePluginDefine.java
index 69136be880c36ea94504cd793818849fd5d28898..8c36f9a48abad768b43c98296b90586d9f173630 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/AbstractDatabasePluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/AbstractDatabasePluginDefine.java
@@ -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";
+ }
+ }};
}
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/JDBCDriverInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/JDBCDriverInterceptor.java
index c040cd5b417846fd8b6ce2e346c0d032adaedb10..6c38e23901da5badf29be2ab9aaf452aacd475d9 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/JDBCDriverInterceptor.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/JDBCDriverInterceptor.java
@@ -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) {
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterInterceptor.java
index 60d4dde68db4cc7a776e8c24425eebb82d0510bc..a8f670de78d64e5b5e2d4a114c4c51dd96da62ec 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterInterceptor.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterInterceptor.java
@@ -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();
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisInterceptor.java
index c6d3e44a9878de6b1c471321d0dfb263ef634302..83911a61f99503c061b2735c6dd10293c6e643f9 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisInterceptor.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisInterceptor.java
@@ -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,
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisClusterPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisClusterPluginDefine.java
index 05be5ada78b15825e6dfa1cb1fd865aeefccc3aa..89abe3a20389c19ee56f374c57c69873c5a8aa0d 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisClusterPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisClusterPluginDefine.java
@@ -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";
+ }
+ }};
}
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisPluginDefine.java
index 3f474a57b464a3e51ea0d16efc7a9f5925b8f343..fbcf6e4553e5fe8e2638bb96eed7ca84cc5b3e71 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisPluginDefine.java
@@ -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";
+ }
+ }};
+ }
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanClientInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanClientInterceptor.java
index f70462bf70993f595800eac42d2be83ad41a1fa5..a8567a392f261c18fcf34e672a101d0e0fcbd74a 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanClientInterceptor.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanClientInterceptor.java
@@ -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]);
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanServerInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanServerInterceptor.java
index 1d0d49c649938923e21f5bb4946bfd4385aa071f..4082ed51c4a2ae481ccf6a2de6f42d7b9d79d8bb 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanServerInterceptor.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanServerInterceptor.java
@@ -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]);
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanClientDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanClientDefine.java
index 5fbf9cc4236ddf4639ed81518c0bbc61780e957a..4c7b4470c3f91737e35b1142b71f3afa076b1e72 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanClientDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanClientDefine.java
@@ -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";
+ }
+ }
+ };
}
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanServerDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanServerDefine.java
index 703196f832a3257f53aa512b4b2af33ac79af310..245199d5e88e8218892229178c87d37c9d03c231 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanServerDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanServerDefine.java
@@ -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";
+ }
+ }};
}
}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatPluginInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatPluginInterceptor.java
index f2f6823b9491fe4c8b8c3a091568c4623e8fb860..a77db1aee8ec971633c8082adb93fe0ab02146ec 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatPluginInterceptor.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatPluginInterceptor.java
@@ -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();
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/define/TomcatPluginDefine.java b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/define/TomcatPluginDefine.java
index 9acf2976be4cd5f43f7dd6fd844e3dcd636ab90b..bab15eba4dee6fdf01e6dd98d5cdb27030ace8e3 100644
--- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/define/TomcatPluginDefine.java
+++ b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/define/TomcatPluginDefine.java
@@ -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")};
+ protected String enhanceClassName() {
+ return "org.apache.catalina.core.StandardEngineValve";
}
@Override
- protected String getInstanceMethodsInterceptor() {
- return "com.a.eye.skywalking.plugin.tomcat78x.TomcatPluginInterceptor";
+ protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
+ return null;
}
@Override
- protected String enhanceClassName() {
- return "org.apache.catalina.core.StandardEngineValve";
+ 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";
+ }
+ }};
}
}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/config/Config.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/config/Config.java
index 755cc4ede98243dc6fbf91d2931f190ab653de91..b92d7eed5acae2d04cc8c17e31a99b01c25fabfa 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/config/Config.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/config/Config.java
@@ -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";
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileWriter.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileWriter.java
index 87e3ca525bdd88f453ac90cd8db3f6675da9ba26..1d4a72ad645868d74dfc5781499fa8ae2e48fed7 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileWriter.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileWriter.java
@@ -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;
}
diff --git a/skywalking-storage-center/skywalking-storage/src/test/java/com/a/eye/skywalking/storage/data/file/DataFileTest.java b/skywalking-storage-center/skywalking-storage/src/test/java/com/a/eye/skywalking/storage/data/file/DataFileTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..469af8e1297960d84dbd360297067a1d9c207226
--- /dev/null
+++ b/skywalking-storage-center/skywalking-storage/src/test/java/com/a/eye/skywalking/storage/data/file/DataFileTest.java
@@ -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());
+ }
+ }
+}