提交 c02c3f3e 编写于 作者: wu-sheng's avatar wu-sheng

1.plugin增加对于拦截所有方法的支持

2.jedis插件工程,上传基本工程结构
上级 dfadae71
......@@ -121,6 +121,7 @@ public class EnhanceClazz4Interceptor {
InterceptPoint[] methodNameList = define.getBeInterceptedMethods();
ClassMethodInterceptor classMethodInterceptor = new ClassMethodInterceptor(
interceptor);
for (InterceptPoint method : methodNameList) {
logger.debug("prepare to enhance class {} method [{}] ",
enhanceOriginClassName, method.getMethodName());
......@@ -134,6 +135,9 @@ public class EnhanceClazz4Interceptor {
named(method.getMethodName()).and(
takesArguments(method.getArgNum()))).intercept(
MethodDelegation.to(classMethodInterceptor));
} else if("*".equals(method.getMethodName())){
newClassBuilder = newClassBuilder.method(any()).intercept(
MethodDelegation.to(classMethodInterceptor));
} else {
newClassBuilder = newClassBuilder.method(
named(method.getMethodName())).intercept(
......
......@@ -16,6 +16,7 @@
<module>httpclient-4.3.x-plugin</module>
<module>httpClient-4.x-plugin</module>
<module>httpClient-4.x-plugin-dubbox-rest-attachment</module>
<module>jedis-2.x-plugin</module>
</modules>
<packaging>pom</packaging>
......
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ai.cloud</groupId>
<artifactId>skywalking-sdk-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>skywalking-jedis-2.x-plugin</artifactId>
<packaging>jar</packaging>
<name>jedis-2.x-plugin</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.ai.cloud</groupId>
<artifactId>skywalking-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
package org.skywalking.jedis.v2.plugin;
import com.ai.cloud.skywalking.plugin.interceptor.ConstructorInvokeContext;
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.ai.cloud.skywalking.plugin.interceptor.IAroundInterceptor;
import com.ai.cloud.skywalking.plugin.interceptor.MethodInvokeContext;
public class JedisInterceptor implements IAroundInterceptor{
@Override
public void onConstruct(EnhancedClassInstanceContext context,
ConstructorInvokeContext interceptorContext) {
}
@Override
public void beforeMethod(EnhancedClassInstanceContext context,
MethodInvokeContext interceptorContext) {
}
@Override
public Object afterMethod(EnhancedClassInstanceContext context,
MethodInvokeContext interceptorContext, Object ret) {
return ret;
}
@Override
public void handleMethodException(Throwable t,
EnhancedClassInstanceContext context,
MethodInvokeContext interceptorContext, Object ret) {
}
}
package org.skywalking.jedis.v2.plugin.define;
import org.skywalking.jedis.v2.plugin.JedisInterceptor;
import com.ai.cloud.skywalking.plugin.interceptor.IAroundInterceptor;
import com.ai.cloud.skywalking.plugin.interceptor.InterceptPoint;
import com.ai.cloud.skywalking.plugin.interceptor.InterceptorDefine;
public class JedisPluginDefine implements InterceptorDefine {
@Override
public String getBeInterceptedClassName() {
return "redis.clients.jedis.Jedis";
}
@Override
public InterceptPoint[] getBeInterceptedMethods() {
return new InterceptPoint[] { new InterceptPoint("*") };
}
@Override
public IAroundInterceptor instance() {
return new JedisInterceptor();
}
}
org.skywalking.jedis.v2.plugin.define.JedisPluginDefine
\ No newline at end of file
package org.skywalking.jedis.v2.plugin;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import org.junit.Test;
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
public class JedisTest {
@Test
public void test() throws IllegalAccessException,
IllegalArgumentException, InvocationTargetException,
NoSuchMethodException, SecurityException, ClassNotFoundException {
TracingBootstrap
.main(new String[] { "org.skywalking.jedis.v2.plugin.JedisTest" });
}
public static void main(String[] args) throws ClassNotFoundException,
SQLException, InterruptedException {}
}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="error">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d [%t](%F:%L) %-5level %logger{36} - %msg%n" />
</Console>
<Console name="Console2" target="SYSTEM_OUT">
<PatternLayout pattern="%d [%t](%F:%L) %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
#skyWalking用户ID
skywalking.user_id=123
#skyWalking应用编码
skywalking.application_code=test
#skywalking auth的环境变量名字
skywalking.auth_system_env_name=SKYWALKING_RUN
#skywalking数据编码
skywalking.charset=UTF-8
#是否打印数据
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
#是否开启发送消息
sender.is_off=false
#最大消费线程数
consumer.max_consumer=2
#消费者最大等待时间
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册