From 59932538fb709a44210c0de897c19b0a18a22811 Mon Sep 17 00:00:00 2001 From: "kangqiang.w" Date: Fri, 19 Oct 2018 12:15:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtprofiler.log=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=BE=93=E5=87=BA=E6=95=B0=E6=8D=AE=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=3D=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mysql/MysqlProfFilter.java | 26 +++++++++++++++++-- .../profile/instrument/ProfTransformer.java | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/taobao/profile/dependence_query/mysql/MysqlProfFilter.java b/src/main/java/com/taobao/profile/dependence_query/mysql/MysqlProfFilter.java index be043d1..7322160 100644 --- a/src/main/java/com/taobao/profile/dependence_query/mysql/MysqlProfFilter.java +++ b/src/main/java/com/taobao/profile/dependence_query/mysql/MysqlProfFilter.java @@ -1,5 +1,8 @@ package com.taobao.profile.dependence_query.mysql; +import java.util.HashSet; +import java.util.Set; + import com.taobao.profile.config.ProfFilter; /** @@ -10,13 +13,32 @@ public class MysqlProfFilter extends ProfFilter { public final static String MysqlPath = "com/mysql/jdbc/ConnectionImpl"; + protected static Set includeMysqlPackage = new HashSet(); + private static MysqlProfFilter instance = new MysqlProfFilter(); protected MysqlProfFilter() { - includePackage.add(MysqlPath.toLowerCase()); + includeMysqlPackage.add(MysqlPath.toLowerCase()); } public static MysqlProfFilter getInstance(){ return instance; } - + + /** + * 为mysql重写isNeedInject方法 + * + * 是否是需要注入的类 + * + * @param className + * @return + */ + public static boolean isNeedInjectMysql(String className) { + String icaseName = className.toLowerCase().replace('.', '/'); + for (String v : includeMysqlPackage) { + if (icaseName.startsWith(v)) { + return true; + } + } + return false; + } } diff --git a/src/main/java/com/taobao/profile/instrument/ProfTransformer.java b/src/main/java/com/taobao/profile/instrument/ProfTransformer.java index d07a385..a3c215f 100644 --- a/src/main/java/com/taobao/profile/instrument/ProfTransformer.java +++ b/src/main/java/com/taobao/profile/instrument/ProfTransformer.java @@ -42,7 +42,7 @@ public class ProfTransformer implements ClassFileTransformer { private byte[] transform4Mysql(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer){ try { - if(!MysqlProfFilter.getInstance().isNeedInject(className)){ + if(!MysqlProfFilter.isNeedInjectMysql(className)){ return null; } From f2fd88782cd3404465c70be22f161dcd926c67bb Mon Sep 17 00:00:00 2001 From: "kangqiang.w" Date: Fri, 19 Oct 2018 12:32:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?README=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README b/README index 513788b..9a4a101 100644 --- a/README +++ b/README @@ -2,10 +2,12 @@ TProfiler is a code profiling tool. author:shutong.dy@taobao.com -Note: TProfiler requires Java6™ VM. +Note: TProfiler requires Java6鈩� VM. Please refer to Wiki for more information: https://github.com/alibaba/TProfiler/wiki The source code is available using the GPL version 2. We are actively looking for contributors, so if you have any ideas, bug reports, or patches you would like to contribute please do not hesitate to do that. + +这个TProfiler已经修复tprofiler文件输出为=的bug。 \ No newline at end of file From 2cd1f829c4c783bf33d709d43d441fa9085ebd70 Mon Sep 17 00:00:00 2001 From: "kangqiang.w" Date: Fri, 19 Oct 2018 12:48:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=92=A4=E9=94=80readme=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README b/README index 9a4a101..513788b 100644 --- a/README +++ b/README @@ -2,12 +2,10 @@ TProfiler is a code profiling tool. author:shutong.dy@taobao.com -Note: TProfiler requires Java6鈩� VM. +Note: TProfiler requires Java6™ VM. Please refer to Wiki for more information: https://github.com/alibaba/TProfiler/wiki The source code is available using the GPL version 2. We are actively looking for contributors, so if you have any ideas, bug reports, or patches you would like to contribute please do not hesitate to do that. - -这个TProfiler已经修复tprofiler文件输出为=的bug。 \ No newline at end of file