From c83792cd0398169ec9d29455b97f934561b22a06 Mon Sep 17 00:00:00 2001 From: ascrutae Date: Mon, 1 Aug 2016 07:19:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8DLogger=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=AF=BC=E8=87=B4Classloader=E9=97=AE=E9=A2=98=202.=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dlogger=E6=97=A5=E5=BF=97=E7=9A=84=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98=203.=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DBytebuddy=E7=9A=84Agent=E7=9A=84=E7=B1=BB=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E7=9A=84=E6=95=88=E7=8E=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dubbo-impl/bin/startSampleDubboService.sh | 26 +++++++ .../example-dubbo/dubbo-impl/pom.xml | 21 ++++-- .../src/main/resources/sky-walking.auth | 45 ------------ .../skywalking-example/example-dubbo/pom.xml | 68 +++++++++++++++++++ .../skywalking/agent/SkywalkingAgent.java | 27 ++------ .../junction/SkyWalkingEnhanceMatcher.java | 10 ++- skywalking-collector/skywalking-api/pom.xml | 19 ++++++ .../com/ai/cloud/skywalking/conf/Config.java | 18 +++-- .../skywalking/logging/SyncFileWriter.java | 17 ++--- .../plugin/PluginDefineCategory.java | 40 +++++++++-- .../cloud/matcher/ExclusionMatcherTest.java | 2 +- .../plugin/PluginDefineCategoryTest.java | 61 +++++++++++++++++ .../skywalking-log/log4j-1.x-plugin/pom.xml | 1 + .../skywalking-log/log4j-2.x-plugin/pom.xml | 1 + .../skywalking-log/logback-plugin/pom.xml | 3 +- 15 files changed, 266 insertions(+), 93 deletions(-) create mode 100644 samples/skywalking-example/example-dubbo/dubbo-impl/bin/startSampleDubboService.sh delete mode 100644 samples/skywalking-example/example-dubbo/dubbo-impl/src/main/resources/sky-walking.auth create mode 100644 skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/PluginDefineCategoryTest.java diff --git a/samples/skywalking-example/example-dubbo/dubbo-impl/bin/startSampleDubboService.sh b/samples/skywalking-example/example-dubbo/dubbo-impl/bin/startSampleDubboService.sh new file mode 100644 index 000000000..65d426bb7 --- /dev/null +++ b/samples/skywalking-example/example-dubbo/dubbo-impl/bin/startSampleDubboService.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# Get standard environment variables +SAMPLE_DUBBO_BIN_PATH=$(cd `dirname $0`; pwd) +SAMPLE_DUBBO_CFG_DIR="${SAMPLE_DUBBO_BIN_PATH}/../config" +SAMPLE_DUBBO_LIB_DIR="${SAMPLE_DUBBO_BIN_PATH}/../lib" +SAMPLE_DUBBO_LOG_DIR="${SAMPLE_DUBBO_BIN_PATH}/../log" + +#echo $SW_SERVER_BIN_DIR +#set java home +if [ "$JAVA_HOME" != "" ]; then + JAVA="$JAVA_HOME/bin/java" +else + JAVA=java +fi + +CLASSPATH="$SAMPLE_DUBBO_CFG_DIR:$CLASSPATH" + +for i in "${SAMPLE_DUBBO_LIB_DIR}"/*.jar +do + CLASSPATH="$i:$CLASSPATH" +done + +echo "CLASSPATH=$CLASSPATH" + +$JAVA -javaagent:${SAMPLE_DUBBO_BIN_PATH}/../agent/skywalking-agent-1.0-Final.jar -classpath $CLASSPATH com.ai.cloud.skywalking.sample.util.DubboStart diff --git a/samples/skywalking-example/example-dubbo/dubbo-impl/pom.xml b/samples/skywalking-example/example-dubbo/dubbo-impl/pom.xml index 719cef063..6308a20ef 100644 --- a/samples/skywalking-example/example-dubbo/dubbo-impl/pom.xml +++ b/samples/skywalking-example/example-dubbo/dubbo-impl/pom.xml @@ -78,6 +78,22 @@ h2 1.4.192 + + com.ai.cloud + skywalking-log4j-1.x-plugin + 1.0-Final + + + com.ai.cloud + skywalking-log4j-2.x-plugin + 1.0-Final + + + com.ai.cloud + skywalking-api + 1.0-Final + test + org.mybatis mybatis @@ -89,10 +105,5 @@ RELEASE test - - com.ai.cloud - skywalking-log4j-1.x-plugin - 1.0-Final - diff --git a/samples/skywalking-example/example-dubbo/dubbo-impl/src/main/resources/sky-walking.auth b/samples/skywalking-example/example-dubbo/dubbo-impl/src/main/resources/sky-walking.auth deleted file mode 100644 index 9be01f6e3..000000000 --- a/samples/skywalking-example/example-dubbo/dubbo-impl/src/main/resources/sky-walking.auth +++ /dev/null @@ -1,45 +0,0 @@ -#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 - -#是否打印数据 -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 - diff --git a/samples/skywalking-example/example-dubbo/pom.xml b/samples/skywalking-example/example-dubbo/pom.xml index 1822da887..fe075b7c6 100644 --- a/samples/skywalking-example/example-dubbo/pom.xml +++ b/samples/skywalking-example/example-dubbo/pom.xml @@ -20,4 +20,72 @@ UTF-8 + + + + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + + + ${project.build.directory}/installer/lib + false + true + + + + maven-jar-plugin + + ${project.build.directory}/installer/lib + + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + + copy-start-script + package + + copy-resources + + + ${project.build.directory}/installer/bin + + + bin + false + + + + + + + + maven-antrun-plugin + + + clean + package + + run + + + + + + + + + + + + diff --git a/skywalking-collector/skywalking-agent/src/main/java/com/ai/cloud/skywalking/agent/SkywalkingAgent.java b/skywalking-collector/skywalking-agent/src/main/java/com/ai/cloud/skywalking/agent/SkywalkingAgent.java index 11cc68691..55affef79 100644 --- a/skywalking-collector/skywalking-agent/src/main/java/com/ai/cloud/skywalking/agent/SkywalkingAgent.java +++ b/skywalking-collector/skywalking-agent/src/main/java/com/ai/cloud/skywalking/agent/SkywalkingAgent.java @@ -11,44 +11,29 @@ import net.bytebuddy.agent.builder.AgentBuilder; import net.bytebuddy.description.NamedElement; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.dynamic.DynamicType; -import net.bytebuddy.matcher.BooleanMatcher; import net.bytebuddy.matcher.ElementMatcher; -import net.bytebuddy.matcher.ElementMatchers; import java.io.File; import java.lang.instrument.Instrumentation; import java.net.URL; import java.util.List; -import static net.bytebuddy.matcher.ElementMatchers.any; -import static net.bytebuddy.matcher.ElementMatchers.named; - public class SkywalkingAgent { - private static Logger logger = LogManager.getLogger(SkywalkingAgent.class); - - + private static Logger logger = LogManager.getLogger(SkywalkingAgent.class); + private static final PluginDefineCategory pluginDefineCategory = PluginDefineCategory.category(new PluginBootstrap().loadPlugins()); public static void premain(String agentArgs, Instrumentation instrumentation) throws PluginException { initConfig(); if (AuthDesc.isAuth()) { - List plugins = new PluginBootstrap().loadPlugins(); - logger.info("Loaded " + plugins.size() + " plugin"); - final PluginDefineCategory pluginDefineCategory = PluginDefineCategory.category(plugins); - startBootPluginDefines(pluginDefineCategory.getBootPluginsDefines()); new AgentBuilder.Default().type(exclusivePackageClass()).transform(new AgentBuilder.Transformer() { public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription, ClassLoader classLoader) { - AbstractClassEnhancePluginDefine pluginDefine = pluginDefineCategory.getClassEnhancePluginDefines().get(typeDescription.getTypeName()); - if (pluginDefine == null) { - return builder; - } - + AbstractClassEnhancePluginDefine pluginDefine = pluginDefineCategory.findPluginDefine(typeDescription.getTypeName()); try { return pluginDefine.define(builder); } catch (Throwable e) { - e.printStackTrace(); logger.error("Failed to enhance plugin " + pluginDefine.getClass().getName(), e); return builder; } @@ -59,11 +44,11 @@ public class SkywalkingAgent { } private static ElementMatcher.Junction exclusivePackageClass() { - return myMatcher(); + return enhanceClassMatcher(); } - private static ElementMatcher.Junction myMatcher() { - return new SkyWalkingEnhanceMatcher(); + private static ElementMatcher.Junction enhanceClassMatcher() { + return new SkyWalkingEnhanceMatcher(pluginDefineCategory); } diff --git a/skywalking-collector/skywalking-agent/src/main/java/com/ai/cloud/skywalking/agent/junction/SkyWalkingEnhanceMatcher.java b/skywalking-collector/skywalking-agent/src/main/java/com/ai/cloud/skywalking/agent/junction/SkyWalkingEnhanceMatcher.java index 38b30b129..67e795660 100644 --- a/skywalking-collector/skywalking-agent/src/main/java/com/ai/cloud/skywalking/agent/junction/SkyWalkingEnhanceMatcher.java +++ b/skywalking-collector/skywalking-agent/src/main/java/com/ai/cloud/skywalking/agent/junction/SkyWalkingEnhanceMatcher.java @@ -1,13 +1,21 @@ package com.ai.cloud.skywalking.agent.junction; +import com.ai.cloud.skywalking.plugin.PluginDefineCategory; import net.bytebuddy.description.NamedElement; /** * Created by wusheng on 16/7/31. */ public class SkyWalkingEnhanceMatcher extends AbstractJunction { + + private final PluginDefineCategory pluginDefineCategory; + + public SkyWalkingEnhanceMatcher(PluginDefineCategory pluginDefineCategory) { + this.pluginDefineCategory = pluginDefineCategory; + } + @Override public boolean matches(T target) { - return false; + return pluginDefineCategory.findPluginDefine(target.getSourceCodeName()) != null ? true : false; } } diff --git a/skywalking-collector/skywalking-api/pom.xml b/skywalking-collector/skywalking-api/pom.xml index 9a51daef0..41f400f46 100644 --- a/skywalking-collector/skywalking-api/pom.xml +++ b/skywalking-collector/skywalking-api/pom.xml @@ -50,6 +50,25 @@ gson 2.7 + + junit + junit + 4.11 + test + + + org.powermock + powermock-api-mockito + 1.6.5 + test + + + + org.powermock + powermock-module-junit4 + 1.6.5 + test + diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java index 9c0ef3c96..3aadab0b6 100644 --- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java +++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java @@ -20,6 +20,7 @@ public class Config { public static String AGENT_BASE_PATH = ""; } + public static class BuriedPoint { // 是否打印埋点信息 public static boolean PRINTF = false; @@ -33,9 +34,10 @@ public class Config { public static String EXCLUSIVE_EXCEPTIONS = ""; } + public static class Consumer { // 最大消费线程数 - public static int MAX_CONSUMER = 2; + public static int MAX_CONSUMER = 2; // 消费者最大等待时间 public static long MAX_WAIT_TIME = 5L; @@ -43,6 +45,7 @@ public class Config { public static long CONSUMER_FAIL_RETRY_WAIT_INTERVAL = 50L; } + public static class Buffer { // 每个Buffer的最大个数 public static int BUFFER_MAX_SIZE = 20000; @@ -51,11 +54,12 @@ public class Config { public static int POOL_SIZE = 5; } + public static class Sender { // 最大发送数据个数 public static final int MAX_SEND_DATA_SIZE = 10; // 最大发送者的连接数阀比例 - public static int CONNECT_PERCENT = 50; + public static int CONNECT_PERCENT = 50; // 发送服务端配置 public static String SERVERS_ADDR = "127.0.0.1:34000"; @@ -80,18 +84,20 @@ public class Config { public static long RETRY_FIND_CONNECTION_SENDER = 1000; } + public static class HealthCollector { // 默认健康检查上报时间 public static long REPORT_INTERVAL = 5 * 60 * 1000L; } + public static class Logging { // log文件名 - public static String LOG_FILE_NAME = "skywalking-api.log"; - // log文件路径 - public static String LOG_FILE_PATH = "/tmp/skywalking"; + public static String LOG_FILE_NAME = "skywalking-api.log"; + // log文件文件夹名字 + public static String LOG_DIR_NAME = "logs"; // 最大文件大小 - public static int MAX_LOG_FILE_LENGTH = 3 * 1024 * 1024; + public static int MAX_LOG_FILE_LENGTH = 3 * 1024 * 1024; // skywalking 系统错误文件日志 public static String SYSTEM_ERROR_LOG_FILE_NAME = "skywalking-api-error.log"; } diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/logging/SyncFileWriter.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/logging/SyncFileWriter.java index 37b946468..35a771a85 100644 --- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/logging/SyncFileWriter.java +++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/logging/SyncFileWriter.java @@ -12,7 +12,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import static com.ai.cloud.skywalking.conf.Config.Logging.LOG_FILE_NAME; -import static com.ai.cloud.skywalking.conf.Config.Logging.LOG_FILE_PATH; +import static com.ai.cloud.skywalking.conf.Config.Logging.LOG_DIR_NAME; +import static com.ai.cloud.skywalking.conf.Config.SkyWalking.AGENT_BASE_PATH; public class SyncFileWriter implements IWriter { @@ -23,12 +24,12 @@ public class SyncFileWriter implements IWriter { private SyncFileWriter() { try { - File logFilePath = new File(LOG_FILE_PATH); + File logFilePath = new File(AGENT_BASE_PATH,LOG_DIR_NAME); if (!logFilePath.exists()) { logFilePath.mkdirs(); } - os = new FileOutputStream(new File(LOG_FILE_PATH, LOG_FILE_NAME), true); - bufferSize = Long.valueOf(new File(LOG_FILE_PATH, LOG_FILE_NAME).length()).intValue(); + os = new FileOutputStream(new File(logFilePath, LOG_FILE_NAME), true); + bufferSize = Long.valueOf(new File(logFilePath, LOG_FILE_NAME).length()).intValue(); } catch (IOException e) { writeErrorLog(e); } @@ -81,12 +82,12 @@ public class SyncFileWriter implements IWriter { } private void revertInputStream() throws FileNotFoundException { - os = new FileOutputStream(new File(Config.Logging.LOG_FILE_PATH, Config.Logging.LOG_FILE_NAME), true); + os = new FileOutputStream(new File(Config.Logging.LOG_DIR_NAME, Config.Logging.LOG_FILE_NAME), true); } private void renameLogFile() { - new File(Config.Logging.LOG_FILE_PATH, Config.Logging.LOG_FILE_NAME) - .renameTo(new File(Config.Logging.LOG_FILE_PATH, Config.Logging.LOG_FILE_NAME + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))); + new File(Config.Logging.LOG_DIR_NAME, Config.Logging.LOG_FILE_NAME) + .renameTo(new File(Config.Logging.LOG_DIR_NAME, Config.Logging.LOG_FILE_NAME + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))); } private void closeInputStream() throws IOException { @@ -98,7 +99,7 @@ public class SyncFileWriter implements IWriter { private void writeErrorLog(Throwable e) { FileOutputStream fileOutputStream = null; try { - File file = new File(Config.Logging.LOG_FILE_PATH, Config.Logging.SYSTEM_ERROR_LOG_FILE_NAME); + File file = new File(Config.Logging.LOG_DIR_NAME, Config.Logging.SYSTEM_ERROR_LOG_FILE_NAME); fileOutputStream = new FileOutputStream(file, true); fileOutputStream.write(("Failed to init sync File Writer.\n" + LoggingUtil.fetchThrowableStack(e)).getBytes()); } catch (Exception e1) { diff --git a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java index 74a54c66f..eb34b310d 100644 --- a/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java +++ b/skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java @@ -11,13 +11,26 @@ public class PluginDefineCategory { private static PluginDefineCategory pluginDefineCategory; - private final Map classEnhancePluginDefines = new HashMap(); - private final List IBootPluginDefines = new ArrayList(); + private final Map exactClassEnhancePluginDefineMapping = + new HashMap(); + private final List IBootPluginDefines = + new ArrayList(); + private final Map blurryClassEnhancePluginDefineMapping = + new HashMap(); private PluginDefineCategory(List plugins) { for (IPlugin plugin : plugins) { if (plugin instanceof AbstractClassEnhancePluginDefine) { - classEnhancePluginDefines.put(((AbstractClassEnhancePluginDefine) plugin).enhanceClassName(), (AbstractClassEnhancePluginDefine) plugin); + String enhanceClassName = ((AbstractClassEnhancePluginDefine) plugin).enhanceClassName(); + if (enhanceClassName.endsWith("*")) { + // 加上. 为了区分 com.ai.test com.ai.test1 + blurryClassEnhancePluginDefineMapping + .put(enhanceClassName.substring(0, enhanceClassName.length() - 1), + (AbstractClassEnhancePluginDefine) plugin); + } else { + exactClassEnhancePluginDefineMapping + .put(enhanceClassName, (AbstractClassEnhancePluginDefine) plugin); + } } if (plugin instanceof IBootPluginDefine) { @@ -37,8 +50,25 @@ public class PluginDefineCategory { return pluginDefineCategory.IBootPluginDefines; } - public Map getClassEnhancePluginDefines() { - return pluginDefineCategory.classEnhancePluginDefines; + public Map getExactClassEnhancePluginDefineMapping() { + return pluginDefineCategory.exactClassEnhancePluginDefineMapping; } + public Map getBlurryClassEnhancePluginDefineMapping() { + return blurryClassEnhancePluginDefineMapping; + } + + public AbstractClassEnhancePluginDefine findPluginDefine(String enhanceClassName) { + if (exactClassEnhancePluginDefineMapping.containsKey(enhanceClassName)){ + return exactClassEnhancePluginDefineMapping.get(enhanceClassName); + } + + for (Map.Entry entry : blurryClassEnhancePluginDefineMapping.entrySet()){ + if (enhanceClassName.startsWith(entry.getKey())){ + return entry.getValue(); + } + } + + return null; + } } diff --git a/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/matcher/ExclusionMatcherTest.java b/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/matcher/ExclusionMatcherTest.java index eb53248a5..e4fc662c3 100644 --- a/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/matcher/ExclusionMatcherTest.java +++ b/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/matcher/ExclusionMatcherTest.java @@ -20,7 +20,7 @@ public class ExclusionMatcherTest extends TestCase { PluginDefineCategory category = PluginDefineCategory.category(pluginDefines); - for (Map.Entry entry : category.getClassEnhancePluginDefines().entrySet()) { + for (Map.Entry entry : category.getExactClassEnhancePluginDefineMapping().entrySet()) { DynamicType.Builder newClassBuilder = new ByteBuddy().rebase(TypePool.Default.ofClassPath().describe(entry.getKey()).resolve(), ClassFileLocator.ForClassLoader.ofClassPath()); diff --git a/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/PluginDefineCategoryTest.java b/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/PluginDefineCategoryTest.java new file mode 100644 index 000000000..142327658 --- /dev/null +++ b/skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/PluginDefineCategoryTest.java @@ -0,0 +1,61 @@ +package test.ai.cloud.plugin; + +import com.ai.cloud.skywalking.plugin.AbstractClassEnhancePluginDefine; +import com.ai.cloud.skywalking.plugin.IPlugin; +import com.ai.cloud.skywalking.plugin.PluginDefineCategory; +import com.ai.cloud.skywalking.plugin.PluginException; +import net.bytebuddy.dynamic.DynamicType; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; +import static org.powermock.api.mockito.PowerMockito.spy; + +; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(AbstractClassEnhancePluginDefine.class) +public class PluginDefineCategoryTest { + + private PluginDefineCategory pluginDefineCategory; + + @Before + public void init() { + PowerMockito.spy(AbstractClassEnhancePluginDefine.class); + AbstractClassEnhancePluginDefine define1 = spy(new AbstractClassEnhancePluginDefine() { + @Override + protected DynamicType.Builder enhance(String enhanceOriginClassName, + DynamicType.Builder newClassBuilder) throws PluginException { + return null; + } + + @Override + protected String enhanceClassName() { + return "com.ai.test.*"; + } + }); + List plugins = new ArrayList(); + plugins.add(define1); + + pluginDefineCategory = PluginDefineCategory.category(plugins); + } + + @Test + public void testCategory() throws Exception { + assertEquals(1, pluginDefineCategory.getBlurryClassEnhancePluginDefineMapping().size()); + } + + @Test + public void testFindPluginDef() { + assertNotNull(pluginDefineCategory.findPluginDefine("com.ai.test.Test")); + assertNotNull(pluginDefineCategory.findPluginDefine("com.ai.test.test.TestA")); + assertNull(pluginDefineCategory.findPluginDefine("com.ai.test1.test")); + } +} diff --git a/skywalking-collector/skywalking-log/log4j-1.x-plugin/pom.xml b/skywalking-collector/skywalking-log/log4j-1.x-plugin/pom.xml index 411a93611..0f47bd3f2 100644 --- a/skywalking-collector/skywalking-log/log4j-1.x-plugin/pom.xml +++ b/skywalking-collector/skywalking-log/log4j-1.x-plugin/pom.xml @@ -34,6 +34,7 @@ com.ai.cloud skywalking-api 1.0-Final + provided diff --git a/skywalking-collector/skywalking-log/log4j-2.x-plugin/pom.xml b/skywalking-collector/skywalking-log/log4j-2.x-plugin/pom.xml index 81253acce..ef1d54d39 100644 --- a/skywalking-collector/skywalking-log/log4j-2.x-plugin/pom.xml +++ b/skywalking-collector/skywalking-log/log4j-2.x-plugin/pom.xml @@ -28,6 +28,7 @@ com.ai.cloud skywalking-api 1.0-Final + provided org.apache.logging.log4j diff --git a/skywalking-collector/skywalking-log/logback-plugin/pom.xml b/skywalking-collector/skywalking-log/logback-plugin/pom.xml index c5d865877..db2e03e7e 100644 --- a/skywalking-collector/skywalking-log/logback-plugin/pom.xml +++ b/skywalking-collector/skywalking-log/logback-plugin/pom.xml @@ -30,6 +30,7 @@ com.ai.cloud skywalking-api 1.0-Final + provided @@ -52,4 +53,4 @@ https://api.bintray.com/maven/wu-sheng/skywalking/com.ai.cloud.skywalking-log4j-1.x-plugin/;publish=1 - \ No newline at end of file + -- GitLab