Commit ef07b164 authored by 吴晟's avatar 吴晟
Browse files

1.调整拦截器接口,增加interceptPoint描述,重构拦截器接口。重构增强逻辑

2.移除jdbc-plugin
3.新增mysql-plugin,新增插件skywalking-mysql-plugin。插件将在包引用后自动生效。(本地测试完成,待集成测试)
parent 4f606cab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public class LocalBuriedPointSender extends ApplicationExceptionHandler implemen

        if (Config.BuriedPoint.PRINTF) {
            logger.debug("TraceId:" + spanData.getTraceId() + "\tviewpointId:" + spanData.getViewPointId() + "\tParentLevelId:" + spanData.
                    getParentLevel() + "\tLevelId:" + spanData.getLevelId());
                    getParentLevel() + "\tLevelId:" + spanData.getLevelId() + "\tbusinessKey:" + spanData.getBusinessKey());
        }

        // 存放到本地发送进程中
+0 −1
Original line number Diff line number Diff line
package com.ai.cloud.skywalking.plugin;

import java.net.URL;
import java.util.Enumeration;
import java.util.List;

import org.apache.logging.log4j.LogManager;
+4 −4
Original line number Diff line number Diff line
@@ -19,10 +19,10 @@ public class PluginCfg {
	void load(InputStream input) throws IOException{
		try{
			BufferedReader reader = new BufferedReader(new InputStreamReader(input));
			String nhanceOriginClassName = null;
			while((nhanceOriginClassName = reader.readLine()) != null){
				if(!StringUtil.isEmpty(nhanceOriginClassName)){
					interceptorClassList.add(nhanceOriginClassName.trim());
			String interceptorDefineClassName = null;
			while((interceptorDefineClassName = reader.readLine()) != null){
				if(!StringUtil.isEmpty(interceptorDefineClassName)){
					interceptorClassList.add(interceptorDefineClassName.trim());
				}
			}
		}finally{
+9 −1
Original line number Diff line number Diff line
@@ -48,6 +48,14 @@ public class ClassMethodInterceptor {
		Object ret = null;
		try {
			ret =  zuper.call();
		} catch(Throwable t){
			try {
				interceptor.handleMethodException(t, instanceContext, interceptorContext, ret);
				throw t;
			} catch (Throwable t2) {
				logger.error("class[{}] handle method[{}] exception failue:{}",
						obj.getClass(), method.getName(), t2.getMessage(), t2);
			}
		}finally {
			try {
				ret = interceptor.afterMethod(instanceContext, interceptorContext, ret);
+26 −9
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ package com.ai.cloud.skywalking.plugin.interceptor;

import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.any;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;

import java.util.Set;

@@ -80,8 +82,8 @@ public class EnhanceClazz4Interceptor {
		 * 1.add field '_$EnhancedClassInstanceContext' of type
		 * EnhancedClassInstanceContext <br/>
		 * 
		 * 2.intercept constructor by default, and intercept method which it's required by
		 * interceptorDefineClass. <br/>
		 * 2.intercept constructor by default, and intercept method which it's
		 * required by interceptorDefineClass. <br/>
		 */
		IAroundInterceptor interceptor = define.instance();

@@ -90,7 +92,7 @@ public class EnhanceClazz4Interceptor {
		newClassBuilder = newClassBuilder
				.defineField(contextAttrName,
						EnhancedClassInstanceContext.class)
				.constructor(isConstructor())
				.constructor(any())
				.intercept(
						SuperMethodCall.INSTANCE.andThen(MethodDelegation.to(
								new ClassConstructorInterceptor(interceptor))
@@ -99,12 +101,27 @@ public class EnhanceClazz4Interceptor {
												FieldGetter.class,
												FieldSetter.class))));

		String[] methodNameList = define.getBeInterceptedMethods();
		for (String methodName : methodNameList) {
			newClassBuilder = newClassBuilder.method(named(methodName))
					.intercept(
							MethodDelegation.to(new ClassMethodInterceptor(
									interceptor)));
		InterceptPoint[] methodNameList = define.getBeInterceptedMethods();
		ClassMethodInterceptor classMethodInterceptor = new ClassMethodInterceptor(
				interceptor);
		for (InterceptPoint method : methodNameList) {
			logger.debug("prepare to enhance class {} method [{}] ",
					enhanceOriginClassName, method.getMethodName());
			if (method.getArgTypeArray() != null) {
				newClassBuilder = newClassBuilder.method(
						named(method.getMethodName()).and(
								takesArguments(method.getArgTypeArray()))).intercept(
						MethodDelegation.to(classMethodInterceptor));
			} else if (method.getArgNum() > -1) {
				newClassBuilder = newClassBuilder.method(
						named(method.getMethodName()).and(
								takesArguments(method.getArgNum()))).intercept(
						MethodDelegation.to(classMethodInterceptor));
			} else {
				newClassBuilder = newClassBuilder.method(
						named(method.getMethodName())).intercept(
						MethodDelegation.to(classMethodInterceptor));
			}
		}

		/**
Loading