提交 809e3d7b 编写于 作者: A ascrutae

Merge remote-tracking branch 'origin/master'

......@@ -15,7 +15,6 @@
<module>skywalking-storage-center</module>
<module>skywalking-opentracing-kit</module>
<module>samples/skywalking-auth</module>
<module>samples/skywalking-example</module>
</modules>
<packaging>pom</packaging>
......
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-auth</artifactId>
<version>2.0-2016</version>
<packaging>jar</packaging>
<name>skywalking-auth</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
#skyWalking用户ID
skywalking.user_id=18
#skyWalking应用编码
skywalking.application_code=meet-web
#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=false
#自定义插件拦截的包前缀
plugin.customlocalmethodinterceptorplugin.package_prefix=
#自定义插件是否记录入参
plugin.customlocalmethodinterceptorplugin.record_param_enable=false
package com.a.eye.skywalking.network.listener.client;
import com.a.eye.skywalking.network.grpc.SendResult;
/**
* Created by wusheng on 2016/11/27.
*/
......
......@@ -91,7 +91,11 @@ public class Agent2RoutingClient extends Thread {
spanStorageClient.sendACKSpan(ackData);
while (!listener.isBatchFinished()) {
LockSupport.parkNanos(1);
try {
Thread.sleep(10L);
} catch (InterruptedException e) {
}
}
} else {
try {
......
......@@ -20,13 +20,9 @@ public class ConfigInitializer {
if (Config.SkyWalking.IS_PREMAIN_MODE) {
configFileStream = fetchAuthFileInputStream();
} else {
configFileStream = ConfigInitializer.class.getResourceAsStream("/sky-walking.auth");
configFileStream = ConfigInitializer.class.getResourceAsStream("/sky-walking.config");
}
Config.SkyWalking.USER_ID = System.getProperty("userId");
Config.SkyWalking.APPLICATION_CODE = System.getProperty("applicationCode");
Config.SkyWalking.SERVERS = System.getProperty("servers");
if (configFileStream == null) {
logger.info("Not provide sky-walking certification documents, sky-walking api run in default config.");
} else {
......@@ -38,6 +34,9 @@ public class ConfigInitializer {
logger.error("Failed to read the config file, sky-walking api run in default config.", e);
}
}
Config.SkyWalking.USER_ID = System.getProperty("userId");
Config.SkyWalking.APPLICATION_CODE = System.getProperty("applicationCode");
Config.SkyWalking.SERVERS = System.getProperty("servers");
if(StringUtil.isEmpty(Config.SkyWalking.USER_ID)){
throw new ExceptionInInitializerError("'-DuserId=' is missing.");
......
package com.a.eye.skywalking.plugin.bytebuddy;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
/**
* Created by wusheng on 2016/12/1.
*/
public class ArgumentTypeNameMatch implements ElementMatcher<MethodDescription> {
private int index;
private String argumentTypeName;
public ArgumentTypeNameMatch(int index, String argumentTypeName) {
this.index = index;
this.argumentTypeName = argumentTypeName;
}
@Override
public boolean matches(MethodDescription target) {
return target.getParameters().get(index).getType().asErasure().getName().equals(argumentTypeName);
}
}
package com.a.eye.skywalking.plugin.interceptor;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
/**
* Created by wusheng on 2016/11/29.
*/
public interface ConstructorInterceptPoint{
ElementMatcher<MethodDescription> getConstructorMatcher();
/**
*
* @return represents a class name, the class instance must instanceof InstanceConstructorInterceptor.
......
......@@ -68,8 +68,7 @@ public abstract class MethodMatcher {
}
public enum Modifier {
Public, Default, Private, Protected,
ClassLoadingStrategy;
Public, Default, Private, Protected;
private ElementMatcher.Junction<MethodDescription> elementMatcher() {
switch (this) {
......
......@@ -33,11 +33,11 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
}
private DynamicType.Builder<?> enhanceInstance(String enhanceOriginClassName, DynamicType.Builder<?> newClassBuilder) throws PluginException {
ConstructorInterceptPoint constructorInterceptPoint = getConstructorsInterceptPoint();
ConstructorInterceptPoint[] constructorInterceptPoints = getConstructorsInterceptPoints();
InstanceMethodsInterceptPoint[] instanceMethodsInterceptPoints = getInstanceMethodsInterceptPoints();
boolean existedConstructorInterceptPoint = false;
if (constructorInterceptPoint != null) {
if (constructorInterceptPoints != null && constructorInterceptPoints.length > 0) {
existedConstructorInterceptPoint = true;
}
boolean existedMethodsInterceptPoints = false;
......@@ -61,19 +61,25 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
* EnhancedClassInstanceContext <br/>
*
*/
String constructorInterceptor;
newClassBuilder = newClassBuilder.defineField(contextAttrName, EnhancedClassInstanceContext.class, ACC_PRIVATE);
/**
* 2. enhance constructors
*/
if (existedConstructorInterceptPoint) {
constructorInterceptor = constructorInterceptPoint.getConstructorInterceptor();
} else {
constructorInterceptor = "com.a.eye.skywalking.plugin.interceptor.assist.DefaultConstructorInterceptor";
for (ConstructorInterceptPoint constructorInterceptPoint : constructorInterceptPoints) {
newClassBuilder = newClassBuilder.constructor(constructorInterceptPoint.getConstructorMatcher())
.intercept(SuperMethodCall.INSTANCE.andThen(
MethodDelegation.to(new ClassConstructorInterceptor(constructorInterceptPoint.getConstructorInterceptor()))
.appendParameterBinder(FieldProxy.Binder.install(FieldGetter.class, FieldSetter.class))));
}
}
newClassBuilder = newClassBuilder.defineField(contextAttrName, EnhancedClassInstanceContext.class, ACC_PRIVATE);
newClassBuilder = newClassBuilder.constructor(any()).intercept(SuperMethodCall.INSTANCE
.andThen(MethodDelegation.to(new ClassConstructorInterceptor(constructorInterceptor)).appendParameterBinder(FieldProxy.Binder.install(FieldGetter.class, FieldSetter.class))));
if(existedMethodsInterceptPoints) {
/**
* 3. enhance instance methods
*/
if (existedMethodsInterceptPoints) {
for (InstanceMethodsInterceptPoint instanceMethodsInterceptPoint : instanceMethodsInterceptPoints) {
String interceptor = instanceMethodsInterceptPoint.getMethodsInterceptor();
......@@ -113,7 +119,7 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
return newClassBuilder;
}
protected abstract ConstructorInterceptPoint getConstructorsInterceptPoint();
protected abstract ConstructorInterceptPoint[] getConstructorsInterceptPoints();
protected abstract InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints();
......@@ -121,7 +127,7 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
private DynamicType.Builder<?> enhanceClass(String enhanceOriginClassName, DynamicType.Builder<?> newClassBuilder) throws PluginException {
StaticMethodsInterceptPoint[] staticMethodsInterceptPoints = getStaticMethodsInterceptPoints();
if(staticMethodsInterceptPoints == null || staticMethodsInterceptPoints.length == 0){
if (staticMethodsInterceptPoints == null || staticMethodsInterceptPoints.length == 0) {
return newClassBuilder;
}
......
......@@ -13,7 +13,7 @@ public abstract class ClassStaticMethodsEnhancePluginDefine extends
ClassEnhancePluginDefine {
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint(){
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints(){
return null;
}
......
package com.a.eye.skywalking.context;
import com.a.eye.skywalking.model.Span;
import org.junit.Test;
import org.mockito.Mockito;
import static org.junit.Assert.*;
import static org.mockito.Mockito.verify;
public class CurrentThreadSpanStackTest {
@Test
public void testStack(){
Span rootSpan = new Span("test","test","Test");
Span subSpan1 = new Span("test","0", 10, "test","Test");
Span subSpan2 = new Span("test","0", 10, "test","Test");
CurrentThreadSpanStack.push(rootSpan);
CurrentThreadSpanStack.push(subSpan1);
Span span = CurrentThreadSpanStack.peek();
assertEquals(0, span.getLevelId());
CurrentThreadSpanStack.pop();
CurrentThreadSpanStack.push(subSpan2);
span = CurrentThreadSpanStack.peek();
assertEquals(1, span.getLevelId());
CurrentThreadSpanStack.pop();
CurrentThreadSpanStack.pop();
}
}
package test.a.eye.cloud.assertspandata;
import com.a.eye.skywalking.buffer.ContextBuffer;
import com.a.eye.skywalking.conf.Config;
import com.a.eye.skywalking.protocol.RequestSpan;
import com.a.eye.skywalking.model.Span;
import com.a.eye.skywalking.testframework.api.RequestSpanAssert;
import org.junit.Test;
/**
* Created by xin on 16-6-6.
*/
public class SDKGeneratedDataTest {
@Test
public void traceTreeAssertTest() {
Config.Consumer.MAX_CONSUMER = 0;
Span testSpan = new Span("1.0b.1465224457414.7e57f54.22905.61.2691", "", 0, "test-application", "5");
RequestSpan requestSpan =
RequestSpan.RequestSpanBuilder.newBuilder(testSpan).viewPoint("http://hire.asiainfo.com/Aisse-Mobile-Web/aisseWorkPage/submitReimbursement").build();
ContextBuffer.save(requestSpan);
RequestSpanAssert.assertEquals(new String[][] {{"0", "http://hire.asiainfo.com/Aisse-Mobile-Web/aisseWorkPage/submitReimbursement", null}});
}
}
package test.a.eye.cloud.checksum;
import org.junit.Test;
public class CheckSumTest {
private static final int dataIndex = 2;
private static final int MAX_TEST_COUNT = 100_000_00;
@Test
public void TestAllXORSum() {
String data = dataArray[dataIndex];
long startTime = System.currentTimeMillis();
for (int i = 0; i < MAX_TEST_COUNT; i++) {
intToBytes2(makeChecksum(data, 1));
}
System.out.println("All XOR check sum totalSize:" + MAX_TEST_COUNT + " cost :" + (((System.currentTimeMillis() - startTime))));
}
@Test
public void Test18XORSum() {
String data = dataArray[dataIndex];
long startTime = System.currentTimeMillis();
for (int i = 0; i < MAX_TEST_COUNT; i++) {
intToBytes2(makeChecksum(data, 8));
}
System.out.println("All XOR check sum totalSize:" + MAX_TEST_COUNT + " cost :" + (((System.currentTimeMillis() - startTime))));
}
@Test
public void Test116XORSum() {
String data = dataArray[dataIndex];
long startTime = System.currentTimeMillis();
for (int i = 0; i < MAX_TEST_COUNT; i++) {
intToBytes2(makeChecksum(data, 16));
}
System.out.println("All XOR check sum totalSize:" + MAX_TEST_COUNT + " cost :" + (((System.currentTimeMillis() - startTime))));
}
public int makeChecksum(String data, int step) {
char[] dataArray = data.toCharArray();
int result = dataArray[0];
for (int i = 0; i < dataArray.length; i = i + step) {
result ^= dataArray[i];
}
return result;
}
public byte[] intToBytes2(int value) {
byte[] src = new byte[4];
src[0] = (byte) ((value >> 24) & 0xFF);
src[1] = (byte) ((value >> 16) & 0xFF);
src[2] = (byte) ((value >> 8) & 0xFF);
src[3] = (byte) (value & 0xFF);
return src;
}
private static final String[] dataArray = new String[]{
"1.0b.1463530404744.9576be7.22045.45.1480@~0@~0@~com.ai.aisse.controller.overtimeexpense.OvertimeExpenseC" +
"ontroller.overtimeInit(com.ai.net.xss.wrapper.XssRequestWrapper,org.apache.catalina.connector.ResponseFa" +
"cade,org.springframework.validation.support.BindingAwareModelMap)@~1463530404774@~5@~ITSC-MIS-LEV-web01/" +
"10.1.31.12@~0@~ @~M@~false@~ @~22045@~aisse-mobile-web@~5@~L#&",
"1.0b.1463539216140.50f8123.14804.265333.1493@~0.0.0@~3@~tracing:jdbc:oracle:thin:@10.1.1.61:1521:OAPROD(" +
"aisse)@~1463539212130@~1@~ITSC-MIS-LEV-web01/10.1.31.12@~0@~ @~J@~false@~connection.commit@~10872@~aisse" +
"-dubbo@~5@~L#&1.0b.1463539217412.50f8123.14804.52.1556@~0.0.0@~1@~com.ai.aisse.core.dao.impl.AisseItemLi" +
"stTDaoImpl.queryAisseItemWorkMealTs(java.util.LinkedHashMap)@~1463539213376@~6@~ITSC-MIS-LEV-web01/10.1." +
"31.12@~0@~ @~M@~false@~ @~10872@~aisse-dubbo@~5@~L#&1.0b.1463539217412.50f8123.14804.52.1556@~0.0.0@~2@~" +
"tracing:jdbc:oracle:thin:@10.1.1.61:1521:OAPROD(aisse)@~1463539213384@~1@~ITSC-MIS-LEV-web01/10.1.31.12@" +
"~0@~ @~J@~false@~connection.commit@~10872@~aisse-dubbo@~5@~L#&1.0b.1463539217412.50f8123.14804.52.1556@~" +
"0.0@~0@~rest://10.1.31.12:20188/aisse/com.ai.aisse.core.rest.IAisseVoucherApi.queryAisseItemT(Map)@~1463" +
"539213354@~32@~ITSC-MIS-LEV-web01/10.1.31.12@~0@~ @~D@~true@~ @~10872@~aisse-dubbo@~5@~S#&",
"1.0b.1463540545212.3627470.24702.142.5@~ @~0@~Map com.ai.saas.comment.core.service.impl.EvalutionObjSvIm" +
"pl.getCommentsParamters(RequestData)@~1463540545212@~32@~host-10-1-236-126/127.0.0.1@~1@~java.lang.Runti" +
"meException: Value for ntAccount cannot be null#~ at com.ai.saas.comment.core.model.dto.EvalutionO" +
"bjectResultCriteria$GeneratedCriteria.addCriterion(EvalutionObjectResultCriteria.java:116)#~ at com.a" +
"i.saas.comment.core.model.dto.EvalutionObjectResultCriteria$GeneratedCriteria.andNtAccountEqualTo(Evalut" +
"ionObjectResultCriteria.java:479)#~ at com.ai.saas.comment.core.model.dto.EvalutionObjectResultCrite" +
"ria$Criteria.andNtAccountEqualTo(EvalutionObjectResultCriteria.java:1089)#~ at com.ai.saas.comment.c" +
"ore.service.impl.EvalutionObjSvImpl.getCommentsParamters(EvalutionObjSvImpl.java:327)#~ at com.ai.saas.c" +
"omment.core.service.impl.EvalutionObjSvImpl$$FastClassBySpringCGLIB$$e4328417.invoke(<generated>)#~" +
"at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)#~ at org.springframework.a" +
"op.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)#~ at org.s" +
"pringframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)#~" +
"at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(Transactio" +
"nInterceptor.java:99)#~ at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWi" +
"thinTransaction(TransactionAspectSupport.java:281)#~ at org.springframework.transaction.interceptor.T" +
"ransactionInterceptor.invoke(TransactionInterceptor.java:96)#~ at org.springframework.aop.framework.Ref" +
"lectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)#~ at org.springframework.aop.frame" +
"work.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)#~ at com.ai.saas.c" +
"omment.core.service.impl.EvalutionObjSvImpl$$EnhancerBySpringCGLIB$$9d683df1.getCommentsParamters(<gener" +
"ated>)#~ at com.ai.saas.comment.core.service.impl.EvalutionObjSvImpl$$FastClassBySpringCGLIB$$e43" +
"28417.invoke(<generated>)#~ at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:2" +
"04)#~ at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAo" +
"pProxy.java:720)#~ at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)#~ at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.p" +
"roceed(MethodInvocationProceedingJoinPoint.java:85)#~ at com.a.eye.skywalking.plugin.spring.Tracing" +
"Aspect.doTracing(TracingAspect.java:13)#~ at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown " +
"Source)#~ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)" +
"#~ at java.lang.reflect.Method.invoke(Method.java:606)#~ at org.springframework.aop.aspectj.Abstr" +
"actAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)#~ at org.springfra" +
"mework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)#~ at org.s" +
"pringframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)#~ at org.springfra" +
"mework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)#~ at org.s" +
"pringframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)#~" +
" at com.ai.saas.comment.core.service.impl.EvalutionObjSvImpl$$EnhancerBySpringCGLIB$$312c8477.get" +
"CommentsParamters(<generated>)#~ at com.ai.saas.comment.core.api.impl.ObjectCommentApiImpl.getCom" +
"mentsParamters(ObjectCommentApiImpl.java:43)#~ at com.alibaba.dubbo.common.bytecode.Wrapper5.invokeMeth" +
"od(Wrapper5.java)#~ at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(Javass" +
"istProxyFactory.java:46)#~ at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxy" +
"Invoker.java:72)#~ at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)#" +
"~ at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)#~ at com.a" +
"libaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)#~ at com.a" +
"libaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)#~ at com.alibaba.dubbo.rpc.protoco" +
"l.Pr@~M@~false@~ @~24702@~saas-comment-servers@~5@~L#&"
};
}
package test.a.eye.cloud.list;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
/**
* Created by xin on 16-7-2.
*/
public class ArrayListTest {
private List<String> data = new ArrayList<>();
@Before
public void initData() {
data.add("AAAA");
data.add("AAAAB");
data.add("AAAAB");
data.add("AAAAB");
}
@Test
public void testPop() {
data.remove(data.size() - 1);
assertEquals(data.size(), 3);
}
@Test
public void testPush() {
data.add(data.size(), "BBBBB");
assertEquals(data.get(data.size() - 1), "BBBBB");
}
}
package test.a.eye.cloud.logging;
import com.a.eye.skywalking.conf.Config;
import com.a.eye.skywalking.logging.LogManager;
import com.a.eye.skywalking.logging.EasyLogger;
import org.junit.Test;
public class LoggingTest {
EasyLogger easyLogger = LogManager.getLogger(LoggingTest.class);
@Test
public void testNormalLogging() {
easyLogger.debug("Hello World");
}
@Test
public void testErrorLogging() {
easyLogger.error("Hello World", new RuntimeException("Failed message"));
}
@Test
public void testConvertFile() {
Config.Logging.MAX_LOG_FILE_LENGTH = 2400;
easyLogger.error("Hello World", new RuntimeException("Failed message"));
}
}
package test.a.eye.cloud.matcher;
import com.a.eye.skywalking.plugin.AbstractClassEnhancePluginDefine;
import com.a.eye.skywalking.plugin.PluginBootstrap;
import com.a.eye.skywalking.plugin.PluginDefineCategory;
import com.a.eye.skywalking.plugin.PluginException;
import junit.framework.TestCase;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.dynamic.ClassFileLocator;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
import net.bytebuddy.pool.TypePool;
import org.junit.Test;
import java.util.List;
import java.util.Map;
public class ExclusionMatcherTest extends TestCase {
@Test
public void testMatcher()
throws ClassNotFoundException, IllegalAccessException, InstantiationException, InterruptedException,
PluginException {
List<AbstractClassEnhancePluginDefine> pluginDefines = new PluginBootstrap().loadPlugins();
PluginDefineCategory category = PluginDefineCategory.category(pluginDefines);
for (Map.Entry<String, AbstractClassEnhancePluginDefine> entry : category
.getExactClassEnhancePluginDefineMapping().entrySet()) {
DynamicType.Builder<?> newClassBuilder = new ByteBuddy()
.rebase(TypePool.Default.ofClassPath().describe(entry.getKey()).resolve(),
ClassFileLocator.ForClassLoader.ofClassPath());
newClassBuilder = entry.getValue().define(entry.getKey(), newClassBuilder);
newClassBuilder.make().load(ClassLoader.getSystemClassLoader(), ClassLoadingStrategy.Default.INJECTION)
.getLoaded();
}
TestMatcherClass testMatcherClass =
(TestMatcherClass) Class.forName("TestMatcherClass").newInstance();
testMatcherClass.set();
testMatcherClass.seta("a");
testMatcherClass.get("a");
testMatcherClass.find();
System.out.println(testMatcherClass.toString());
testMatcherClass.equals(new TestMatcherClass());
}
}
package test.a.eye.cloud.matcher;
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;
/**
* Created by xin on 16-6-8.
*/
public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
System.out.println("before method");
}
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
System.out.println("after method");
return ret;
}
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
}
}
package test.a.eye.cloud.matcher;
/**
* Created by xin on 16-6-8.
*/
public class TestMatcherClass {
public void set() {
System.out.println("public set()");
}
public void seta(String a) {
System.out.println("public seta(String a)");
set(a);
}
private void set(String a) {
System.out.println("private set(String a)");
}
public void get(String a) {
System.out.println("public get(String a)");
}
public void find() {
System.out.println("public find()");
}
@Override
public String toString() {
return "Call toString()";
}
@Override
public boolean equals(Object obj) {
System.out.println("equals(Object obj)");
return true;
}
}
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;
/**
* Created by xin on 16-6-8.
*/
public class TestMatcherDefine extends ClassInstanceMethodsEnhancePluginDefine {
@Override
public String enhanceClassName() {
return "test.a.eye.cloud.matcher.TestMatcherClass";
}
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
return null;
}
@Override
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";
}
}};
}
}
......@@ -9,7 +9,7 @@ import java.lang.reflect.InvocationTargetException;
public class PluginMainTest {
@Test
public void testMain() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, PluginException {
TracingBootstrap.main(new String[] {"PluginMainTest"});
TracingBootstrap.main(new String[] {"test.a.eye.cloud.plugin.PluginMainTest"});
}
public static void main(String[] args)
......@@ -17,7 +17,7 @@ public class PluginMainTest {
SecurityException {
long start = System.currentTimeMillis();
BeInterceptedClass inst = (BeInterceptedClass) Class.forName("BeInterceptedClass").newInstance();
BeInterceptedClass inst = (BeInterceptedClass) Class.forName("test.a.eye.cloud.plugin.BeInterceptedClass").newInstance();
inst.printabc();
long end = System.currentTimeMillis();
System.out.println(end - start + "ms");
......
......@@ -8,12 +8,6 @@ import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
context.set("test.key", "123");
System.out.println("onConstruct, args size=" + interceptorContext.allArguments().length);
}
@Override
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
System.out.println("beforeMethod : " + context.get("test.key", String.class));
......
package test.a.eye.cloud.plugin;
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.StaticMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine;
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
......@@ -12,23 +15,37 @@ public class TestInterceptorDefine extends ClassEnhancePluginDefine {
}
@Override
public MethodMatcher[] getInstanceMethodsMatchers() {
return new MethodMatcher[] { new SimpleMethodMatcher("printabc") };
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return null;
}
@Override
public String getInstanceMethodsInterceptor() {
return "TestAroundInterceptor";
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
@Override
public MethodMatcher[] getMethodsMatchers() {
return new MethodMatcher[]{new SimpleMethodMatcher("printabc")};
}
@Override
public String getMethodsInterceptor() {
return "TestAroundInterceptor";
}
}};
}
@Override
protected MethodMatcher[] getStaticMethodsMatchers() {
return new MethodMatcher[] { new SimpleMethodMatcher("call") };
protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
return new StaticMethodsInterceptPoint[]{new StaticMethodsInterceptPoint() {
@Override
public MethodMatcher[] getMethodsMatchers() {
return new MethodMatcher[]{new SimpleMethodMatcher("call")};
}
@Override
public String getMethodsInterceptor() {
return "TestStaticAroundInterceptor";
}
}};
}
@Override
protected String getStaticMethodsInterceptor() {
return "TestStaticAroundInterceptor";
}
}
package test.a.eye.cloud.serialize;
import com.a.eye.skywalking.buffer.ContextBuffer;
import com.a.eye.skywalking.protocol.AckSpan;
import com.a.eye.skywalking.model.Span;
import com.a.eye.skywalking.protocol.common.SpanType;
public class SerializeTest {
public static void main(String[] args) throws InterruptedException {
while (true) {
Span spandata = new Span("1.0b.1461060884539.7d6d06e.22489.1271.103", "", 0, "test-application", "test");
spandata.setSpanType(SpanType.LOCAL);
spandata.setStartDate(System.currentTimeMillis() - 1000 * 60);
AckSpan requestSpan = new AckSpan(spandata);
ContextBuffer.save(requestSpan);
Thread.sleep(500);
}
}
}
......@@ -13,7 +13,7 @@ public class DubboPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
}
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return null;
}
......
......@@ -5,7 +5,7 @@ import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhan
public abstract class HttpClientPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return null;
}
......
......@@ -8,7 +8,7 @@ import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhan
public abstract class AbstractDatabasePluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return null;
}
......
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;
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
/**
* Created by xin on 16-6-12.
*/
public class JedisClusterConstructorInterceptor4HostAndPortArg implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
StringBuilder redisConnInfo = new StringBuilder();
HostAndPort hostAndPort = (HostAndPort) interceptorContext.allArguments()[0];
redisConnInfo.append(hostAndPort.toString()).append(";");
context.set(REDIS_CONN_INFO_KEY, redisConnInfo.toString());
}
}
......@@ -8,24 +8,18 @@ import redis.clients.jedis.HostAndPort;
import java.util.Set;
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
/**
* Created by xin on 16-6-12.
*/
public class JedisClusterInterceptor extends JedisBaseInterceptor implements InstanceConstructorInterceptor {
public class JedisClusterConstructorInterceptor4SetArg implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
StringBuilder redisConnInfo = new StringBuilder();
if (interceptorContext.allArguments().length > 0) {
if (interceptorContext.allArguments()[0] instanceof Set) {
@SuppressWarnings("unchecked")
Set<HostAndPort> hostAndPorts = (Set<HostAndPort>) interceptorContext.allArguments()[0];
for (HostAndPort hostAndPort : hostAndPorts) {
redisConnInfo.append(hostAndPort.toString()).append(";");
}
} else if (interceptorContext.allArguments()[0] instanceof HostAndPort) {
HostAndPort hostAndPort = (HostAndPort) interceptorContext.allArguments()[0];
redisConnInfo.append(hostAndPort.toString()).append(";");
}
Set<HostAndPort> hostAndPorts = (Set<HostAndPort>) interceptorContext.allArguments()[0];
for (HostAndPort hostAndPort : hostAndPorts) {
redisConnInfo.append(hostAndPort.toString()).append(";");
}
context.set(REDIS_CONN_INFO_KEY, redisConnInfo.toString());
}
......
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.JedisShardInfo;
import java.net.URI;
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
/**
* Created by wusheng on 2016/12/1.
*/
public class JedisConstructorInterceptor4ShardInfoArg implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
String redisConnInfo;
JedisShardInfo shardInfo = (JedisShardInfo) interceptorContext.allArguments()[0];
redisConnInfo = shardInfo.getHost() + ":" + shardInfo.getPort();
context.set(REDIS_CONN_INFO_KEY, redisConnInfo);
}
}
......@@ -7,27 +7,16 @@ import redis.clients.jedis.JedisShardInfo;
import java.net.URI;
public class JedisInterceptor extends JedisBaseInterceptor implements InstanceConstructorInterceptor {
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
public class JedisConstructorInterceptor4StringArg implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context,
ConstructorInvokeContext interceptorContext) {
String redisConnInfo = "";
if (interceptorContext.allArguments().length > 0) {
if (interceptorContext.allArguments()[0] instanceof String) {
redisConnInfo = (String) interceptorContext.allArguments()[0];
if (interceptorContext.allArguments().length > 1) {
redisConnInfo += ":"
+ (Integer) interceptorContext.allArguments()[1];
}
} else if (interceptorContext.allArguments()[0] instanceof JedisShardInfo) {
JedisShardInfo shardInfo = (JedisShardInfo) interceptorContext
.allArguments()[0];
redisConnInfo = shardInfo.getHost() + ":" + shardInfo.getPort();
} else if (interceptorContext.allArguments()[0] instanceof URI) {
URI uri = (URI) interceptorContext.allArguments()[0];
redisConnInfo = uri.getHost() + ":" + uri.getPort();
}
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
String redisConnInfo;
redisConnInfo = (String) interceptorContext.allArguments()[0];
if (interceptorContext.allArguments().length > 1) {
redisConnInfo += ":" + interceptorContext.allArguments()[1];
}
context.set(REDIS_CONN_INFO_KEY, redisConnInfo);
}
......
package com.a.eye.skywalking.plugin.interceptor.assist;
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 java.net.URI;
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.REDIS_CONN_INFO_KEY;
/**
* Created by wusheng on 2016/11/29.
* Created by wusheng on 2016/12/1.
*/
public class DefaultConstructorInterceptor implements InstanceConstructorInterceptor {
public class JedisConstructorInterceptor4UriArg implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
// do nothing as default implements.
String redisConnInfo;
URI uri = (URI) interceptorContext.allArguments()[0];
redisConnInfo = uri.getHost() + ":" + uri.getPort();
context.set(REDIS_CONN_INFO_KEY, redisConnInfo);
}
}
......@@ -7,7 +7,7 @@ import com.a.eye.skywalking.plugin.interceptor.assist.SimpleObjectFirstInvokeInt
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
public abstract class JedisBaseInterceptor extends SimpleObjectFirstInvokeInterceptor {
public class JedisMethodInterceptor extends SimpleObjectFirstInvokeInterceptor {
protected static final String REDIS_CONN_INFO_KEY = "redisClusterConnInfo";
private static RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
......
package com.a.eye.skywalking.plugin.jedis.v2.define;
import com.a.eye.skywalking.plugin.bytebuddy.ArgumentTypeNameMatch;
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;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import java.util.Set;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
public class JedisClusterPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
......@@ -14,29 +22,41 @@ public class JedisClusterPluginDefine extends ClassInstanceMethodsEnhancePluginD
}
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
return new ConstructorInterceptPoint(){
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, Set.class);
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterInterceptor";
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorInterceptor4SetArg";
}
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return new ArgumentTypeNameMatch(0, "redis.clients.jedis.HostAndPort");
}
};
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorInterceptor4HostAndPortArg";
}
}};
}
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
return new InstanceMethodsInterceptPoint[] {new InstanceMethodsInterceptPoint() {
@Override
public MethodMatcher[] getMethodsMatchers() {
return new MethodMatcher[]{
new AnyMethodsMatcher()
};
return new MethodMatcher[] {new AnyMethodsMatcher()};
}
@Override
public String getMethodsInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterInterceptor";
return "com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor";
}
}};
}
......
package com.a.eye.skywalking.plugin.jedis.v2.define;
import com.a.eye.skywalking.plugin.bytebuddy.ArgumentTypeNameMatch;
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;
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import com.a.eye.skywalking.plugin.interceptor.matcher.MethodsExclusiveMatcher;
import com.a.eye.skywalking.plugin.interceptor.matcher.PrivateMethodMatcher;
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
......@@ -16,37 +22,53 @@ public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
}
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
return new ConstructorInterceptPoint() {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, String.class);
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisInterceptor";
return "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorInterceptor4StringArg";
}
};
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return new ArgumentTypeNameMatch(0, "redis.clients.jedis.HostAndPort");
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorInterceptor4ShardInfoArgg";
}
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, String.class);
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorInterceptor4UriArg";
}
}};
}
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
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")
)
};
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";
return "com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor";
}
}};
}
......
......@@ -13,10 +13,9 @@ import java.util.HashSet;
import java.util.Set;
public class JedisClusterTest {
@Test
public void test() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException,
PluginException {
TracingBootstrap.main(new String[] {"JedisClusterTest"});
TracingBootstrap.main(new String[] {"com.a.eye.skywalking.plugin.jedis.v2.JedisClusterTest"});
}
public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException {
......
......@@ -10,7 +10,6 @@ import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
public class JedisTest {
@Test
public void test() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException,
PluginException {
TracingBootstrap.main(new String[] {"JedisTest"});
......
......@@ -5,6 +5,10 @@ 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;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import static net.bytebuddy.matcher.ElementMatchers.any;
public class MotanClientDefine extends ClassInstanceMethodsEnhancePluginDefine {
@Override
......@@ -13,29 +17,32 @@ public class MotanClientDefine extends ClassInstanceMethodsEnhancePluginDefine {
}
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
return new ConstructorInterceptPoint() {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return any();
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.motan.MotanClientInterceptor";
}
};
}};
}
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{
new InstanceMethodsInterceptPoint() {
@Override
public MethodMatcher[] getMethodsMatchers() {
return new MethodMatcher[] {new SimpleMethodMatcher("call")};
}
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";
}
}
};
@Override
public String getMethodsInterceptor() {
return "com.a.eye.skywalking.plugin.motan.MotanClientInterceptor";
}
}};
}
}
......@@ -5,6 +5,10 @@ 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;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import static net.bytebuddy.matcher.ElementMatchers.any;
public class MotanServerDefine extends ClassInstanceMethodsEnhancePluginDefine {
......@@ -14,18 +18,23 @@ public class MotanServerDefine extends ClassInstanceMethodsEnhancePluginDefine {
}
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
return new ConstructorInterceptPoint() {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return any();
}
@Override
public String getConstructorInterceptor() {
return "com.a.eye.skywalking.plugin.motan.MotanServerInterceptor";
}
};
}};
}
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
return new InstanceMethodsInterceptPoint[] {new InstanceMethodsInterceptPoint() {
@Override
public MethodMatcher[] getMethodsMatchers() {
return new MethodMatcher[] {new SimpleMethodMatcher("call")};
......
......@@ -13,7 +13,7 @@ public class TomcatPluginDefine extends ClassInstanceMethodsEnhancePluginDefine
}
@Override
protected ConstructorInterceptPoint getConstructorsInterceptPoint() {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return null;
}
......
......@@ -34,6 +34,7 @@ public abstract class AbstractRouteSpanEventHandler<T> implements EventHandler<T
SpanStorageClient spanStorageClient = client.newSpanStorageClient(new StorageClientListener() {
@Override
public void onError(Throwable throwable) {
previousSendFinish = true;
HealthCollector.getCurrentHeathReading(getExtraId()).updateData(HeathReading.ERROR, "Failed to send span. error message :" + throwable.getMessage());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册