1.remove *.auth 2.add ArgumentTypeNameMatch 3. use ArgumentTypeNameMatch to Jedis Plugin

This commit is contained in:
wusheng 2016-12-01 17:19:08 +08:00
parent 9430d3dc4e
commit 6bf74b5fc1
10 changed files with 39 additions and 95 deletions

View File

@ -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>

View File

@ -1,25 +0,0 @@
<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>

View File

@ -1,54 +0,0 @@
#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

View File

@ -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.");

View File

@ -0,0 +1,23 @@
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);
}
}

View File

@ -7,7 +7,7 @@ import net.bytebuddy.matcher.ElementMatcher;
* Created by wusheng on 2016/11/29.
*/
public interface ConstructorInterceptPoint{
ElementMatcher.Junction<MethodDescription> getConstructorMatcher();
ElementMatcher<MethodDescription> getConstructorMatcher();
/**
*

View File

@ -1,5 +1,6 @@
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;
@ -24,7 +25,7 @@ public class JedisClusterPluginDefine extends ClassInstanceMethodsEnhancePluginD
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher.Junction<MethodDescription> getConstructorMatcher() {
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, Set.class);
}
@ -34,8 +35,8 @@ public class JedisClusterPluginDefine extends ClassInstanceMethodsEnhancePluginD
}
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher.Junction<MethodDescription> getConstructorMatcher() {
return not(takesArgument(0, Set.class));
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return new ArgumentTypeNameMatch(0, "redis.clients.jedis.HostAndPort");
}
@Override

View File

@ -1,5 +1,6 @@
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;
@ -24,7 +25,7 @@ public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher.Junction<MethodDescription> getConstructorMatcher() {
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, String.class);
}
@ -34,8 +35,8 @@ public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
}
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher.Junction<MethodDescription> getConstructorMatcher() {
return not(takesArgument(0, String.class).or(takesArgument(0, String.class)));
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return new ArgumentTypeNameMatch(0, "redis.clients.jedis.HostAndPort");
}
@Override
@ -44,7 +45,7 @@ public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
}
}, new ConstructorInterceptPoint() {
@Override
public ElementMatcher.Junction<MethodDescription> getConstructorMatcher() {
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(0, String.class);
}

View File

@ -20,7 +20,7 @@ public class MotanClientDefine extends ClassInstanceMethodsEnhancePluginDefine {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher.Junction<MethodDescription> getConstructorMatcher() {
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return any();
}

View File

@ -21,7 +21,7 @@ public class MotanServerDefine extends ClassInstanceMethodsEnhancePluginDefine {
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {new ConstructorInterceptPoint() {
@Override
public ElementMatcher.Junction<MethodDescription> getConstructorMatcher() {
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return any();
}