Skip to content

Commit

Permalink
修复tprofiler.log无法输出数据,只有=号的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
DevenWen committed Oct 19, 2018
1 parent 8344d1a commit 5993253
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand All @@ -10,13 +13,32 @@ public class MysqlProfFilter extends ProfFilter {

public final static String MysqlPath = "com/mysql/jdbc/ConnectionImpl";

protected static Set<String> includeMysqlPackage = new HashSet<String>();

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

1 comment on commit 5993253

@DevenWen
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修复TProfiler日志只有=号的问题

Please sign in to comment.