diff --git a/samples/skywalking-auth/src/main/resources/sky-walking.auth b/samples/skywalking-auth/src/main/resources/sky-walking.auth
index 71f26d069..3fc7372b2 100644
--- a/samples/skywalking-auth/src/main/resources/sky-walking.auth
+++ b/samples/skywalking-auth/src/main/resources/sky-walking.auth
@@ -45,3 +45,10 @@ buffer.pool_size=5
#发送检查线程检查周期
senderchecker.check_polling_time=200
+#自定义本地方法插件是否开启
+plugin.customlocalmethodinterceptorplugin.is_enable=false
+#自定义插件拦截的包前缀
+plugin.customlocalmethodinterceptorplugin.package_prefix=
+#自定义插件是否记录入参
+plugin.customlocalmethodinterceptorplugin.record_param_enable=false
+
diff --git a/skywalking-collector/skywalking-agent/pom.xml b/skywalking-collector/skywalking-agent/pom.xml
index 7492cbd05..4b53b3c8b 100644
--- a/skywalking-collector/skywalking-agent/pom.xml
+++ b/skywalking-collector/skywalking-agent/pom.xml
@@ -51,6 +51,11 @@
tomcat-7.x-8.x-plugin
1.0-Final
+
+ com.ai.cloud
+ custom-local-method-interceptor-plugin
+ 1.0-Final
+
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java
index f45a8104d..0b056fc95 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java
@@ -19,14 +19,22 @@ public class Config {
public static String AGENT_BASE_PATH = "";
- public static boolean SELF_DEFINE_METHOD_INTERCEPTOR = false;
-
- public static String SELF_DEFINE_METHOD_PACKAGE = "";
-
- public static boolean RECORD_PARAM = false;
}
+ public static class Plugin{
+
+ public static class CustomLocalMethodInterceptorPlugin{
+
+ public static boolean IS_ENABLE = false;
+
+ public static String PACKAGE_PREFIX = "";
+
+ public static boolean RECORD_PARAM_ENABLE = false;
+ }
+
+ }
+
public static class BuriedPoint {
// 是否打印埋点信息
public static boolean PRINTF = false;
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/invoke/monitor/BaseInvokeMonitor.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/invoke/monitor/BaseInvokeMonitor.java
index 83b08d7a2..0e6e895e2 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/invoke/monitor/BaseInvokeMonitor.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/invoke/monitor/BaseInvokeMonitor.java
@@ -39,7 +39,7 @@ public abstract class BaseInvokeMonitor {
ContextBuffer.save(RequestSpan.RequestSpanBuilder.
newBuilder(CurrentThreadSpanStack.peek()).callType(id.getCallType()).viewPoint(id.getViewPoint())
.spanTypeDesc(id.getSpanTypeDesc()).processNo(BuriedPointMachineUtil.getProcessNo())
- .address(BuriedPointMachineUtil.getHostDesc()).build());
+ .address(BuriedPointMachineUtil.getHostDesc()).parameters(id.getParameters()).build());
// 并将当前的Context返回回去
return new ContextData(spanData);
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java
index a82928d98..b1379c4ed 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java
@@ -16,6 +16,11 @@ public class PluginDefineCategory {
private PluginDefineCategory(List plugins) {
for (AbstractClassEnhancePluginDefine plugin : plugins) {
String enhanceClassName = plugin.enhanceClassName();
+
+ if (enhanceClassName == null){
+ continue;
+ }
+
if (enhanceClassName.endsWith("*")) {
// 加上. 为了区分 com.ai.test com.ai.test1
blurryClassEnhancePluginDefineMapping
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/TracingBootstrap.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/TracingBootstrap.java
index 8bee30dfb..504db6dc7 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/TracingBootstrap.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/TracingBootstrap.java
@@ -1,5 +1,6 @@
package com.ai.cloud.skywalking.plugin;
+import com.ai.cloud.skywalking.conf.AuthDesc;
import com.ai.cloud.skywalking.logging.LogManager;
import com.ai.cloud.skywalking.logging.Logger;
import net.bytebuddy.ByteBuddy;
@@ -31,6 +32,10 @@ public class TracingBootstrap {
throw new RuntimeException("bootstrap failure. need args[0] to be main class.");
}
+ if (!AuthDesc.isAuth()){
+ return;
+ }
+
List plugins = null;
try {
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java
index 9712981a4..0181c3e36 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java
@@ -28,7 +28,7 @@ public class ClassInstanceMethodsInterceptor {
@FieldValue(ClassEnhancePluginDefine.contextAttrName) EnhancedClassInstanceContext instanceContext) throws Exception {
InstanceMethodsAroundInterceptor interceptor = InterceptorInstanceLoader.load(instanceMethodsAroundInterceptorClassName, obj.getClass().getClassLoader());
- InstanceMethodInvokeContext interceptorContext = new InstanceMethodInvokeContext(obj, method.getName(), allArguments);
+ InstanceMethodInvokeContext interceptorContext = new InstanceMethodInvokeContext(obj, method.getName(), allArguments, method.getParameterTypes());
MethodInterceptResult result = new MethodInterceptResult();
try {
interceptor.beforeMethod(instanceContext, interceptorContext, result);
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java
index 28d6b5587..361a6c05a 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java
@@ -29,7 +29,7 @@ public class ClassStaticMethodsInterceptor {
public Object intercept(@Origin Class> clazz, @AllArguments Object[] allArguments, @Origin Method method, @SuperCall Callable> zuper) throws Exception {
StaticMethodsAroundInterceptor interceptor = InterceptorInstanceLoader.load(staticMethodsAroundInterceptorClassName, clazz.getClassLoader());
- MethodInvokeContext interceptorContext = new MethodInvokeContext(clazz,method.getName(), allArguments);
+ StaticMethodInvokeContext interceptorContext = new StaticMethodInvokeContext(clazz,method.getName(), allArguments, method.getParameterTypes());
MethodInterceptResult result = new MethodInterceptResult();
try {
interceptor.beforeMethod(interceptorContext, result);
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/InstanceMethodInvokeContext.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/InstanceMethodInvokeContext.java
index 42738624c..a8fc6eb88 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/InstanceMethodInvokeContext.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/InstanceMethodInvokeContext.java
@@ -6,8 +6,8 @@ public class InstanceMethodInvokeContext extends MethodInvokeContext {
*/
private Object objInst;
- InstanceMethodInvokeContext(Object objInst, String methodName, Object[] allArguments) {
- super(objInst.getClass(), methodName, allArguments);
+ InstanceMethodInvokeContext(Object objInst, String methodName, Object[] allArguments, Class>[] argumentsTypes) {
+ super(methodName, allArguments,argumentsTypes);
this.objInst = objInst;
}
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/MethodInvokeContext.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/MethodInvokeContext.java
index f5dbbb1e4..07fbc93fc 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/MethodInvokeContext.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/MethodInvokeContext.java
@@ -15,9 +15,12 @@ public class MethodInvokeContext {
*/
private Object[] allArguments;
- MethodInvokeContext(Class clazz, String methodName, Object[] allArguments) {
- this.methodName = appendMethodName(clazz, methodName, allArguments);
+ private Class>[] argumentTypes;
+
+ MethodInvokeContext(String methodName, Object[] allArguments,Class>[] argumentTypes) {
+ this.methodName = methodName;
this.allArguments = allArguments;
+ this.argumentTypes = argumentTypes;
}
public Object[] allArguments() {
@@ -28,17 +31,8 @@ public class MethodInvokeContext {
return methodName;
}
- private String appendMethodName(Class clazz, String simpleMethodName, Object[] allArguments) {
- StringBuilder methodName = new StringBuilder(clazz.getName() + "." + simpleMethodName + "(");
- for (Object argument : allArguments) {
- methodName.append(argument.getClass() + ",");
- }
-
- if (allArguments.length > 0){
- methodName.deleteCharAt(methodName.length() - 1);
- }
-
- methodName.append(")");
- return methodName.toString();
+ public Class>[] argumentTypes(){
+ return argumentTypes;
}
+
}
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodInvokeContext.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodInvokeContext.java
new file mode 100644
index 000000000..bffe0a85f
--- /dev/null
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodInvokeContext.java
@@ -0,0 +1,17 @@
+package com.ai.cloud.skywalking.plugin.interceptor.enhance;
+
+public class StaticMethodInvokeContext extends MethodInvokeContext {
+ /**
+ * 代理类名
+ */
+ private Class clazz;
+
+ StaticMethodInvokeContext(Class clazz, String methodName, Object[] allArguments, Class>[] parameterTypes) {
+ super(methodName, allArguments, parameterTypes);
+ this.clazz = clazz;
+ }
+
+ public Class claszz() {
+ return clazz;
+ }
+}
diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java
index c429153e5..bfca7a3c8 100644
--- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java
+++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java
@@ -2,9 +2,9 @@ package com.ai.cloud.skywalking.plugin.interceptor.enhance;
public interface StaticMethodsAroundInterceptor {
- public void beforeMethod(MethodInvokeContext interceptorContext, MethodInterceptResult result);
+ public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result);
- public Object afterMethod(MethodInvokeContext interceptorContext, Object ret);
+ public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret);
public void handleMethodException(Throwable t, MethodInvokeContext interceptorContext);
}
diff --git a/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/TestStaticAroundInterceptor.java b/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/TestStaticAroundInterceptor.java
index de81e8bf1..ff9ceb1e0 100644
--- a/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/TestStaticAroundInterceptor.java
+++ b/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/TestStaticAroundInterceptor.java
@@ -2,17 +2,18 @@ package test.ai.cloud.plugin;
import com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
import com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInvokeContext;
+import com.ai.cloud.skywalking.plugin.interceptor.enhance.StaticMethodInvokeContext;
import com.ai.cloud.skywalking.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
public class TestStaticAroundInterceptor implements StaticMethodsAroundInterceptor {
@Override
- public void beforeMethod(MethodInvokeContext interceptorContext, MethodInterceptResult result) {
+ public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result) {
System.out.println("beforeMethod : static");
}
@Override
- public Object afterMethod(MethodInvokeContext interceptorContext, Object ret) {
+ public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret) {
System.out.println("afterMethod: static");
return ret;
}
diff --git a/skywalking-collector/skywalking-api/src/test/resources/sky-walking.auth b/skywalking-collector/skywalking-api/src/test/resources/sky-walking.auth
index edfeed871..074398a71 100644
--- a/skywalking-collector/skywalking-api/src/test/resources/sky-walking.auth
+++ b/skywalking-collector/skywalking-api/src/test/resources/sky-walking.auth
@@ -46,3 +46,9 @@ buffer.pool_size=5
#发送检查线程检查周期
senderchecker.check_polling_time=200
+#自定义本地方法插件是否开启
+plugin.customlocalmethodinterceptorplugin.is_enable=true
+#自定义插件拦截的包前缀
+plugin.customlocalmethodinterceptorplugin.package_prefix=test.com.ai.test.*
+#自定义插件是否记录入参
+plugin.customlocalmethodinterceptorplugin.record_param_enable=false
diff --git a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/pom.xml b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/pom.xml
similarity index 83%
rename from skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/pom.xml
rename to skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/pom.xml
index 18e4d63b1..724458b6d 100644
--- a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/pom.xml
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/pom.xml
@@ -7,10 +7,10 @@
4.0.0
- self-define-interceptor-plugin
+ custom-local-method-interceptor-plugin
jar
- self-define-interceptor-plugin
+ custom-local-method-interceptor-plugin
http://maven.apache.org
diff --git a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/SelfDefineMethodInterceptor.java b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodInterceptor.java
similarity index 57%
rename from skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/SelfDefineMethodInterceptor.java
rename to skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodInterceptor.java
index a73805e4e..72abfb6dd 100644
--- a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/SelfDefineMethodInterceptor.java
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodInterceptor.java
@@ -1,4 +1,4 @@
-package com.ai.cloud.skywalking.self.define.plugin;
+package com.ai.cloud.skywalking.plugin.custom.localmethod;
import com.ai.cloud.skywalking.conf.Config;
import com.ai.cloud.skywalking.invoke.monitor.LocalMethodInvokeMonitor;
@@ -7,7 +7,7 @@ import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.ai.cloud.skywalking.plugin.interceptor.enhance.*;
import com.google.gson.Gson;
-public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterceptor, StaticMethodsAroundInterceptor {
+public class CustomLocalMethodInterceptor implements InstanceMethodsAroundInterceptor, StaticMethodsAroundInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
@@ -17,12 +17,15 @@ public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterce
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext,
MethodInterceptResult result) {
Identification.IdentificationBuilder identificationBuilder = buildIdentificationBuilder(interceptorContext);
+ identificationBuilder.spanType(new CustomLocalSpanType()).viewPoint(
+ fullMethodName(interceptorContext.inst().getClass(), interceptorContext.methodName(),
+ interceptorContext.argumentTypes()));
new LocalMethodInvokeMonitor().beforeInvoke(identificationBuilder.build());
}
private Identification.IdentificationBuilder buildIdentificationBuilder(MethodInvokeContext interceptorContext) {
Identification.IdentificationBuilder identificationBuilder = Identification.newBuilder();
- if (Config.SkyWalking.RECORD_PARAM) {
+ if (Config.Plugin.CustomLocalMethodInterceptorPlugin.RECORD_PARAM_ENABLE) {
for (Object param : interceptorContext.allArguments()) {
String paramStr;
try {
@@ -34,7 +37,6 @@ public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterce
}
}
- identificationBuilder.spanType(new SelfDefineSpanType()).viewPoint(interceptorContext.methodName());
return identificationBuilder;
}
@@ -51,13 +53,18 @@ public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterce
new LocalMethodInvokeMonitor().occurException(t);
}
+
@Override
- public void beforeMethod(MethodInvokeContext interceptorContext, MethodInterceptResult result) {
- new LocalMethodInvokeMonitor().beforeInvoke(buildIdentificationBuilder(interceptorContext).build());
+ public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result) {
+ Identification.IdentificationBuilder identificationBuilder = buildIdentificationBuilder(interceptorContext);
+ identificationBuilder.spanType(new CustomLocalSpanType()).viewPoint(
+ fullMethodName(interceptorContext.claszz(), interceptorContext.methodName(),
+ interceptorContext.argumentTypes()));
+ new LocalMethodInvokeMonitor().beforeInvoke(identificationBuilder.build());
}
@Override
- public Object afterMethod(MethodInvokeContext interceptorContext, Object ret) {
+ public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret) {
new LocalMethodInvokeMonitor().afterInvoke();
return ret;
}
@@ -66,4 +73,18 @@ public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterce
public void handleMethodException(Throwable t, MethodInvokeContext interceptorContext) {
new LocalMethodInvokeMonitor().occurException(t);
}
+
+ private String fullMethodName(Class clazz, String simpleMethodName, Object[] allArguments) {
+ StringBuilder methodName = new StringBuilder(clazz.getName() + "." + simpleMethodName + "(");
+ for (Object argument : allArguments) {
+ methodName.append(argument.getClass() + ",");
+ }
+
+ if (allArguments.length > 0) {
+ methodName.deleteCharAt(methodName.length() - 1);
+ }
+
+ methodName.append(")");
+ return methodName.toString();
+ }
}
diff --git a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/SelfDefineSpanType.java b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalSpanType.java
similarity index 69%
rename from skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/SelfDefineSpanType.java
rename to skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalSpanType.java
index 7c854e5d6..658ecd4af 100644
--- a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/SelfDefineSpanType.java
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalSpanType.java
@@ -1,9 +1,9 @@
-package com.ai.cloud.skywalking.self.define.plugin;
+package com.ai.cloud.skywalking.plugin.custom.localmethod;
import com.ai.cloud.skywalking.api.IBuriedPointType;
import com.ai.cloud.skywalking.protocol.common.CallType;
-public class SelfDefineSpanType implements IBuriedPointType {
+public class CustomLocalSpanType implements IBuriedPointType {
@Override
public String getTypeName() {
return "L";
diff --git a/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/define/CustomLocalMethodPluginDefine.java b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/define/CustomLocalMethodPluginDefine.java
new file mode 100644
index 000000000..cfacd0413
--- /dev/null
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/define/CustomLocalMethodPluginDefine.java
@@ -0,0 +1,38 @@
+package com.ai.cloud.skywalking.plugin.custom.localmethod.define;
+
+import com.ai.cloud.skywalking.conf.Config;
+import com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher;
+import com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine;
+import com.ai.cloud.skywalking.plugin.interceptor.matcher.AnyMethodsMatcher;
+
+public class CustomLocalMethodPluginDefine extends ClassEnhancePluginDefine {
+
+ @Override
+ protected MethodMatcher[] getInstanceMethodsMatchers() {
+ return new MethodMatcher[] {new AnyMethodsMatcher()};
+ }
+
+ @Override
+ protected String getInstanceMethodsInterceptor() {
+ return "com.ai.cloud.skywalking.plugin.custom.localmethod.CustomLocalMethodInterceptor";
+ }
+
+ @Override
+ protected MethodMatcher[] getStaticMethodsMatchers() {
+ return new MethodMatcher[] {new AnyMethodsMatcher()};
+ }
+
+ @Override
+ protected String getStaticMethodsInterceptor() {
+ return "com.ai.cloud.skywalking.plugin.custom.localmethod.CustomLocalMethodInterceptor";
+ }
+
+ @Override
+ protected String enhanceClassName() {
+ return "test.com.ai.test.TestObject";
+// if (!Config.Plugin.CustomLocalMethodInterceptorPlugin.IS_ENABLE){
+// return null;
+// }
+// return Config.Plugin.CustomLocalMethodInterceptorPlugin.PACKAGE_PREFIX;
+ }
+}
diff --git a/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/resources/skywalking-plugin.def b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 000000000..498ba178a
--- /dev/null
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1 @@
+com.ai.cloud.skywalking.plugin.custom.localmethod.define.CustomLocalMethodPluginDefine
diff --git a/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodPluginTest.java b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodPluginTest.java
new file mode 100644
index 000000000..322dbd64a
--- /dev/null
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodPluginTest.java
@@ -0,0 +1,28 @@
+package com.ai.cloud.skywalking.plugin.custom.localmethod;
+
+import com.ai.cloud.skywalking.plugin.TracingBootstrap;
+import com.ai.skywalking.testframework.api.RequestSpanAssert;
+import org.junit.Test;
+import test.com.ai.test.TestObject;
+import test.com.ai.test.TestParam;
+
+import java.lang.reflect.InvocationTargetException;
+
+public class CustomLocalMethodPluginTest {
+
+ @Test
+ public void test()
+ throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ TracingBootstrap.main(new String[]{"com.ai.cloud.skywalking.plugin.custom.localmethod.CustomLocalMethodPluginTest"});
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ TestObject testObject = new TestObject();
+ testObject.printlnHelloWorld();
+ TestObject.staticPrintlnHelloWorld("AA", new TestParam());
+ RequestSpanAssert.assertEquals(new String[][] {
+ {"0", "test.com.ai.test.TestObject.printlnHelloWorld()", ""},
+ {"0", "test.com.ai.test.TestObject.staticPrintlnHelloWorld()", ""}
+ });
+ }
+}
diff --git a/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestObject.java b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestObject.java
new file mode 100644
index 000000000..97058f5d2
--- /dev/null
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestObject.java
@@ -0,0 +1,11 @@
+package test.com.ai.test;
+
+public class TestObject {
+ public static void staticPrintlnHelloWorld(String aa, TestParam param){
+ System.out.println("Hello World" + aa);
+ }
+
+ public void printlnHelloWorld(TestParam... params){
+ System.out.println("Hello World");
+ }
+}
diff --git a/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestParam.java b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestParam.java
new file mode 100644
index 000000000..b2f6e6c68
--- /dev/null
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestParam.java
@@ -0,0 +1,7 @@
+package test.com.ai.test;
+
+/**
+ * Created by xin on 16/8/12.
+ */
+public class TestParam {
+}
diff --git a/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/resources/sky-walking.auth b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/resources/sky-walking.auth
new file mode 100644
index 000000000..e3d197ccc
--- /dev/null
+++ b/skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/resources/sky-walking.auth
@@ -0,0 +1,54 @@
+#skyWalking用户ID
+skywalking.user_id=123
+#skyWalking应用编码
+skywalking.application_code=skywalking-sample-dubbo
+#skywalking auth的环境变量名字
+skywalking.auth_system_env_name=SKYWALKING_RUN
+#skywalking数据编码
+skywalking.charset=UTF-8
+skywalking.auth_override=true
+#是否使用STD替换日志输出
+skywalking.logger_std_out_override=false;
+
+#是否打印数据
+buriedpoint.printf=true
+#埋点异常的最大长度
+buriedpoint.max_exception_stack_length=4000
+#业务字段的最大长度
+buriedpoint.businesskey_max_length=300
+#过滤异常
+buriedpoint.exclusive_exceptions=java.lang.RuntimeException
+
+#最大发送者的连接数阀比例
+sender.connect_percent=100
+#发送服务端配置
+sender.servers_addr=127.0.0.1:34000
+#最大发送的副本数量
+sender.max_copy_num=2
+#发送的最大长度
+sender.max_send_length=20000
+#当没有Sender时,尝试获取sender的等待周期
+sender.retry_get_sender_wait_interval=2000
+
+#最大消费线程数
+consumer.max_consumer=1
+#消费者最大等待时间
+consumer.max_wait_time=5
+#发送失败等待时间
+consumer.consumer_fail_retry_wait_interval=50
+
+#每个Buffer的最大个数
+buffer.buffer_max_size=18000
+#Buffer池的最大长度
+buffer.pool_size=5
+
+#发送检查线程检查周期
+senderchecker.check_polling_time=200
+
+#自定义本地方法插件是否开启
+plugin.customlocalmethodinterceptorplugin.is_enable=true
+#自定义插件拦截的包前缀
+plugin.customlocalmethodinterceptorplugin.package_prefix=test.com.ai.test.*
+#自定义插件是否记录入参
+plugin.customlocalmethodinterceptorplugin.record_param_enable=true
+
diff --git a/skywalking-collector/skywalking-sdk-plugin/pom.xml b/skywalking-collector/skywalking-sdk-plugin/pom.xml
index 35c5d9c0d..024e0f836 100644
--- a/skywalking-collector/skywalking-sdk-plugin/pom.xml
+++ b/skywalking-collector/skywalking-sdk-plugin/pom.xml
@@ -16,7 +16,7 @@
httpClient-4.x-plugin
jedis-2.x-plugin
tomcat-7.x-8.x-plugin
- self-define-interceptor-plugin
+ custom-local-method-interceptor-plugin
pom
diff --git a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/define/SelfDefineMethodPluginDefine.java b/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/define/SelfDefineMethodPluginDefine.java
deleted file mode 100644
index 760370cd5..000000000
--- a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/define/SelfDefineMethodPluginDefine.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.ai.cloud.skywalking.self.define.plugin.define;
-
-import com.ai.cloud.skywalking.conf.Config;
-import com.ai.cloud.skywalking.plugin.PluginException;
-import com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher;
-import com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine;
-import com.ai.cloud.skywalking.plugin.interceptor.matcher.AnyMethodsMatcher;
-import net.bytebuddy.dynamic.DynamicType;
-
-public class SelfDefineMethodPluginDefine extends ClassEnhancePluginDefine {
-
- @Override
- protected DynamicType.Builder> enhance(String enhanceOriginClassName, DynamicType.Builder> newClassBuilder)
- throws PluginException {
- return Config.SkyWalking.SELF_DEFINE_METHOD_INTERCEPTOR ?
- super.enhance(enhanceOriginClassName, newClassBuilder) :
- newClassBuilder;
- }
-
- @Override
- protected MethodMatcher[] getInstanceMethodsMatchers() {
- return new MethodMatcher[] {new AnyMethodsMatcher()};
- }
-
- @Override
- protected String getInstanceMethodsInterceptor() {
- return "com.ai.cloud.skywalking.self.define.plugin.SelfDefineMethodInterceptor";
- }
-
- @Override
- protected MethodMatcher[] getStaticMethodsMatchers() {
- return new MethodMatcher[] {new AnyMethodsMatcher()};
- }
-
- @Override
- protected String getStaticMethodsInterceptor() {
- return "com.ai.cloud.skywalking.self.define.plugin.SelfDefineMethodInterceptor";
- }
-
- @Override
- protected String enhanceClassName() {
- if (!Config.SkyWalking.SELF_DEFINE_METHOD_PACKAGE.endsWith(".*")) {
- return Config.SkyWalking.SELF_DEFINE_METHOD_PACKAGE + ".*";
- }
- return Config.SkyWalking.SELF_DEFINE_METHOD_PACKAGE;
- }
-}
diff --git a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/resources/skywalking-plugin.def b/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/resources/skywalking-plugin.def
deleted file mode 100644
index bf7f2aa7f..000000000
--- a/skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/resources/skywalking-plugin.def
+++ /dev/null
@@ -1 +0,0 @@
-com.ai.cloud.skywalking.self.define.plugin.define.SelfDefineMethodPluginDefine
diff --git a/skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/RequestSpan.java b/skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/RequestSpan.java
index 2a14cc070..b79d62369 100644
--- a/skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/RequestSpan.java
+++ b/skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/RequestSpan.java
@@ -111,6 +111,7 @@ public class RequestSpan extends AbstractDataSerializable {
public RequestSpan() {
}
+
private boolean isEntrySpan() {
return "0".equals(this.getParentLevel() + this.getLevelId());
}
@@ -214,7 +215,7 @@ public class RequestSpan extends AbstractDataSerializable {
TraceProtocol.RequestSpan.newBuilder().setTraceId(traceId).setParentLevel(parentLevel)
.setLevelId(levelId).setViewPointId(viewPointId).setStartDate(startDate)
.setSpanType(spanType.getValue()).setSpanTypeDesc(spanTypeDesc).setAddress(address)
- .setProcessNo(processNo);
+ .setProcessNo(processNo);
if (businessKey != null && businessKey.length() > 0) {
builder.setBussinessKey(businessKey);
}
@@ -246,6 +247,7 @@ public class RequestSpan extends AbstractDataSerializable {
requestSpan.setAgentId(requestSpanByte.getAgentId());
requestSpan.setProcessNo(requestSpanByte.getProcessNo());
requestSpan.setAddress(requestSpanByte.getAddress());
+ requestSpan.setParameters(requestSpanByte.getParametersMap());
} catch (InvalidProtocolBufferException e) {
throw new ConvertFailedException(e.getMessage(), e);
}
@@ -254,7 +256,7 @@ public class RequestSpan extends AbstractDataSerializable {
}
public static RequestSpan convert(byte[] data) throws ConvertFailedException {
- return (RequestSpan)INSTANCE.convertData(data);
+ return (RequestSpan) INSTANCE.convertData(data);
}
public void setBusinessKey(String businessKey) {
@@ -310,10 +312,7 @@ public class RequestSpan extends AbstractDataSerializable {
}
public RequestSpanBuilder parameters(Map parameters) {
- if (requestSpan.isEntrySpan()) {
- requestSpan.parameters = parameters;
- }
-
+ requestSpan.parameters = parameters;
return this;
}
@@ -326,12 +325,12 @@ public class RequestSpan extends AbstractDataSerializable {
return this;
}
- public RequestSpanBuilder processNo(String processNo){
+ public RequestSpanBuilder processNo(String processNo) {
requestSpan.processNo = processNo;
return this;
}
- public RequestSpanBuilder address(String address){
+ public RequestSpanBuilder address(String address) {
requestSpan.address = address;
return this;
}
diff --git a/test/skywalking-agent-test/agent/sky-walking.auth b/test/skywalking-agent-test/agent/sky-walking.auth
new file mode 100644
index 000000000..810f20182
--- /dev/null
+++ b/test/skywalking-agent-test/agent/sky-walking.auth
@@ -0,0 +1,54 @@
+#skyWalking用户ID
+skywalking.user_id=123
+#skyWalking应用编码
+skywalking.application_code=skywalking-sample-dubbo
+#skywalking auth的环境变量名字
+skywalking.auth_system_env_name=SKYWALKING_RUN
+#skywalking数据编码
+skywalking.charset=UTF-8
+skywalking.auth_override=true
+#是否使用STD替换日志输出
+skywalking.logger_std_out_override=false;
+
+#是否打印数据
+buriedpoint.printf=true
+#埋点异常的最大长度
+buriedpoint.max_exception_stack_length=4000
+#业务字段的最大长度
+buriedpoint.businesskey_max_length=300
+#过滤异常
+buriedpoint.exclusive_exceptions=java.lang.RuntimeException
+
+#最大发送者的连接数阀比例
+sender.connect_percent=100
+#发送服务端配置
+sender.servers_addr=127.0.0.1:34000
+#最大发送的副本数量
+sender.max_copy_num=2
+#发送的最大长度
+sender.max_send_length=20000
+#当没有Sender时,尝试获取sender的等待周期
+sender.retry_get_sender_wait_interval=2000
+
+#最大消费线程数
+consumer.max_consumer=0
+#消费者最大等待时间
+consumer.max_wait_time=5
+#发送失败等待时间
+consumer.consumer_fail_retry_wait_interval=50
+
+#每个Buffer的最大个数
+buffer.buffer_max_size=18000
+#Buffer池的最大长度
+buffer.pool_size=5
+
+#发送检查线程检查周期
+senderchecker.check_polling_time=200
+
+#自定义本地方法插件是否开启
+plugin.customlocalmethodinterceptorplugin.is_enable=true
+#自定义插件拦截的包前缀
+plugin.customlocalmethodinterceptorplugin.package_prefix=test.com.ai.cloud.skywalking.agent.test.custom.localmethod.*
+#自定义插件是否记录入参
+plugin.customlocalmethodinterceptorplugin.record_param_enable=true
+
diff --git a/test/skywalking-agent-test/custom-local-method-test/pom.xml b/test/skywalking-agent-test/custom-local-method-test/pom.xml
new file mode 100644
index 000000000..bdde272ba
--- /dev/null
+++ b/test/skywalking-agent-test/custom-local-method-test/pom.xml
@@ -0,0 +1,15 @@
+
+
+
+ skywalking-agent-test
+ com.ai.cloud
+ 1.0-Final
+
+ 4.0.0
+
+ custom-local-method-test
+
+
+
diff --git a/test/skywalking-agent-test/custom-local-method-test/src/main/java/com/ai/cloud/skywalking/agent/test/custom/localmethod/CustomLocalMethodPluginTest.java b/test/skywalking-agent-test/custom-local-method-test/src/main/java/com/ai/cloud/skywalking/agent/test/custom/localmethod/CustomLocalMethodPluginTest.java
new file mode 100644
index 000000000..f67be4abc
--- /dev/null
+++ b/test/skywalking-agent-test/custom-local-method-test/src/main/java/com/ai/cloud/skywalking/agent/test/custom/localmethod/CustomLocalMethodPluginTest.java
@@ -0,0 +1,19 @@
+package com.ai.cloud.skywalking.agent.test.custom.localmethod;
+
+import com.ai.skywalking.testframework.api.RequestSpanAssert;
+import test.com.ai.cloud.skywalking.agent.test.custom.localmethod.TestObject;
+import test.com.ai.cloud.skywalking.agent.test.custom.localmethod.TestParam;
+
+public class CustomLocalMethodPluginTest {
+
+ public static void main(String[] args) throws InterruptedException {
+ TestObject testObject = new TestObject();
+ TestObject.staticPrintlnHelloWorld("AAAA", new TestParam("A", "B"));
+ testObject.printlnHelloWorld(new TestParam("B", "C"));
+
+ RequestSpanAssert.assertEquals(new String[][] {
+ {"0", "test.com.ai.cloud.skywalking.agent.test.custom.localmethod.TestObject.printlnHelloWorld()", ""},
+ {"0", "test.com.ai.cloud.skywalking.agent.test.custom.localmethod.TestObject.staticPrintlnHelloWorld()", ""}
+ },true);
+ }
+}
diff --git a/test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestObject.java b/test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestObject.java
new file mode 100644
index 000000000..e74028a40
--- /dev/null
+++ b/test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestObject.java
@@ -0,0 +1,12 @@
+package test.com.ai.cloud.skywalking.agent.test.custom.localmethod;
+
+public class TestObject {
+
+ public static void staticPrintlnHelloWorld(String aa, TestParam param){
+ System.out.println("Hello World" + aa);
+ }
+
+ public void printlnHelloWorld(TestParam... params){
+ System.out.println("Hello World");
+ }
+}
diff --git a/test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestParam.java b/test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestParam.java
new file mode 100644
index 000000000..f19a44b50
--- /dev/null
+++ b/test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestParam.java
@@ -0,0 +1,15 @@
+package test.com.ai.cloud.skywalking.agent.test.custom.localmethod;
+
+/**
+ * Created by xin on 16/8/12.
+ */
+public class TestParam {
+ private String a;
+ private String b;
+
+ public TestParam(String a, String b) {
+ this.a = a;
+ this.b = b;
+ }
+
+}
diff --git a/test/skywalking-agent-test/pom.xml b/test/skywalking-agent-test/pom.xml
index c80ff5c02..3cf570b5c 100644
--- a/test/skywalking-agent-test/pom.xml
+++ b/test/skywalking-agent-test/pom.xml
@@ -13,7 +13,7 @@
redis-test
jdbc-test
- dubbo-test
+ custom-local-method-test
@@ -36,7 +36,6 @@
com.ai.cloud
skywalking-test-api
1.0-Final
- test