提交 f50566dc 编写于 作者: A ascrutae

修复bug

上级 fa2fdb4e
......@@ -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
......@@ -51,6 +51,11 @@
<artifactId>tomcat-7.x-8.x-plugin</artifactId>
<version>1.0-Final</version>
</dependency>
<dependency>
<groupId>com.ai.cloud</groupId>
<artifactId>custom-local-method-interceptor-plugin</artifactId>
<version>1.0-Final</version>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -19,13 +19,21 @@ 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 {
// 是否打印埋点信息
......
......@@ -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);
......
......@@ -16,6 +16,11 @@ public class PluginDefineCategory {
private PluginDefineCategory(List<AbstractClassEnhancePluginDefine> plugins) {
for (AbstractClassEnhancePluginDefine plugin : plugins) {
String enhanceClassName = plugin.enhanceClassName();
if (enhanceClassName == null){
continue;
}
if (enhanceClassName.endsWith("*")) {
// 加上. 为了区分 com.ai.test com.ai.test1
blurryClassEnhancePluginDefineMapping
......
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<AbstractClassEnhancePluginDefine> plugins = null;
try {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
}
}
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;
}
}
......@@ -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);
}
......@@ -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;
}
......
......@@ -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
......@@ -7,10 +7,10 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>self-define-interceptor-plugin</artifactId>
<artifactId>custom-local-method-interceptor-plugin</artifactId>
<packaging>jar</packaging>
<name>self-define-interceptor-plugin</name>
<name>custom-local-method-interceptor-plugin</name>
<url>http://maven.apache.org</url>
<properties>
......
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();
}
}
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";
......
package com.ai.cloud.skywalking.self.define.plugin.define;
package com.ai.cloud.skywalking.plugin.custom.localmethod.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;
}
public class CustomLocalMethodPluginDefine extends ClassEnhancePluginDefine {
@Override
protected MethodMatcher[] getInstanceMethodsMatchers() {
......@@ -24,7 +14,7 @@ public class SelfDefineMethodPluginDefine extends ClassEnhancePluginDefine {
@Override
protected String getInstanceMethodsInterceptor() {
return "com.ai.cloud.skywalking.self.define.plugin.SelfDefineMethodInterceptor";
return "com.ai.cloud.skywalking.plugin.custom.localmethod.CustomLocalMethodInterceptor";
}
@Override
......@@ -34,14 +24,15 @@ public class SelfDefineMethodPluginDefine extends ClassEnhancePluginDefine {
@Override
protected String getStaticMethodsInterceptor() {
return "com.ai.cloud.skywalking.self.define.plugin.SelfDefineMethodInterceptor";
return "com.ai.cloud.skywalking.plugin.custom.localmethod.CustomLocalMethodInterceptor";
}
@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;
return "test.com.ai.test.TestObject";
// if (!Config.Plugin.CustomLocalMethodInterceptorPlugin.IS_ENABLE){
// return null;
// }
// return Config.Plugin.CustomLocalMethodInterceptorPlugin.PACKAGE_PREFIX;
}
}
com.ai.cloud.skywalking.plugin.custom.localmethod.define.CustomLocalMethodPluginDefine
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()", ""}
});
}
}
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");
}
}
package test.com.ai.test;
/**
* Created by xin on 16/8/12.
*/
public class TestParam {
}
#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
......@@ -16,7 +16,7 @@
<module>httpClient-4.x-plugin</module>
<module>jedis-2.x-plugin</module>
<module>tomcat-7.x-8.x-plugin</module>
<module>self-define-interceptor-plugin</module>
<module>custom-local-method-interceptor-plugin</module>
</modules>
<packaging>pom</packaging>
......
......@@ -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<String, String> 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;
}
......
#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
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>skywalking-agent-test</artifactId>
<groupId>com.ai.cloud</groupId>
<version>1.0-Final</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>custom-local-method-test</artifactId>
</project>
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);
}
}
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");
}
}
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;
}
}
......@@ -13,7 +13,7 @@
<modules>
<module>redis-test</module>
<module>jdbc-test</module>
<module>dubbo-test</module>
<module>custom-local-method-test</module>
</modules>
<properties>
......@@ -36,7 +36,6 @@
<groupId>com.ai.cloud</groupId>
<artifactId>skywalking-test-api</artifactId>
<version>1.0-Final</version>
<scope>test</scope>
</dependency>
</dependencies>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册