add:callNum

This commit is contained in:
huoyo 2024-09-07 20:07:27 +08:00
parent 8888c8bae8
commit 9cf146ff5b
14 changed files with 138 additions and 25 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.langpy</groupId> <groupId>cn.langpy</groupId>
<artifactId>ko-time</artifactId> <artifactId>ko-time</artifactId>
<version>2.4.6</version> <version>2.4.7</version>
<name>KoTime</name> <name>KoTime</name>
<description>A springboot tool for tracking the paths of the methods,which can help you find method's performances easily.</description> <description>A springboot tool for tracking the paths of the methods,which can help you find method's performances easily.</description>
<licenses> <licenses>

View File

@ -12,11 +12,11 @@ public class KoSqlConstant {
"join ko_exception_relation r on e.id = r.target_id"; "join ko_exception_relation r on e.id = r.target_id";
public final static String queryException = "SELECT id, name, class_name FROM ko_exception_node WHERE id=?"; public final static String queryException = "SELECT id, name, class_name FROM ko_exception_node WHERE id=?";
public final static String queryExceptionExist = "SELECT id FROM ko_exception_node WHERE id=?"; public final static String queryExceptionExist = "SELECT id FROM ko_exception_node WHERE id=?";
public final static String addMethodRe = "INSERT INTO ko_method_relation(id, source_id, target_id, avg_run_time, max_run_time, min_run_time) VALUES (?, ?, ?, ?, ?, ?)"; public final static String addMethodRe = "INSERT INTO ko_method_relation(id, source_id, target_id, avg_run_time, max_run_time, min_run_time, call_num) VALUES (?, ?, ?, ?, ?, ?, ?)";
public final static String queryMethodRe = "SELECT id, source_id, target_id, avg_run_time, max_run_time, min_run_time FROM ko_method_relation WHERE id=?"; public final static String queryMethodRe = "SELECT id, source_id, target_id, avg_run_time, max_run_time, min_run_time,call_num FROM ko_method_relation WHERE id=?";
public final static String queryMethodReBySource = "SELECT id, source_id, target_id, avg_run_time, max_run_time, min_run_time FROM ko_method_relation WHERE source_id=?"; public final static String queryMethodReBySource = "SELECT id, source_id, target_id, avg_run_time, max_run_time, min_run_time,call_num FROM ko_method_relation WHERE source_id=?";
public final static String queryMethodReByTarget = "SELECT id, source_id, target_id, avg_run_time, max_run_time, min_run_time FROM ko_method_relation WHERE target_id=?"; public final static String queryMethodReByTarget = "SELECT id, source_id, target_id, avg_run_time, max_run_time, min_run_time,call_num FROM ko_method_relation WHERE target_id=?";
public final static String updateMethodRe = "UPDATE ko_method_relation SET source_id=?, target_id=?, avg_run_time=?, max_run_time=?, min_run_time=? WHERE id=?"; public final static String updateMethodRe = "UPDATE ko_method_relation SET source_id=?, target_id=?, avg_run_time=?, max_run_time=?, min_run_time=?, call_num=? WHERE id=?";
public final static String addExceptionRe = "INSERT INTO ko_exception_relation(id, source_id, target_id, location,message) VALUES (?, ?, ?, ?, ?)"; public final static String addExceptionRe = "INSERT INTO ko_exception_relation(id, source_id, target_id, location,message) VALUES (?, ?, ?, ?, ?)";
public final static String queryExceptionRe = "SELECT id, source_id, target_id, location, message FROM ko_exception_relation WHERE id=?"; public final static String queryExceptionRe = "SELECT id, source_id, target_id, location, message FROM ko_exception_relation WHERE id=?";
public final static String queryExceptionReExist = "SELECT id FROM ko_exception_relation WHERE id=?"; public final static String queryExceptionReExist = "SELECT id FROM ko_exception_relation WHERE id=?";
@ -28,17 +28,17 @@ public class KoSqlConstant {
public final static String updateParamsAna = "UPDATE ko_param_ana SET avg_run_time=?, max_run_time=?, min_run_time=? WHERE source_id=? and params=?"; public final static String updateParamsAna = "UPDATE ko_param_ana SET avg_run_time=?, max_run_time=?, min_run_time=? WHERE source_id=? and params=?";
public final static String queryControllers = "select m.id,name,class_name,method_name,method_type,route_name,r.avg_run_time,r.max_run_time,r.min_run_time " + public final static String queryControllers = "select m.id,name,class_name,method_name,method_type,route_name,r.avg_run_time,r.max_run_time,r.min_run_time,r.call_num " +
"from ko_method_node m " + "from ko_method_node m " +
"join ko_method_relation r on m.id = r.target_id " + "join ko_method_relation r on m.id = r.target_id " +
"where m.method_type='Controller'"; "where m.method_type='Controller'";
public final static String searchMethodsByName = "select m.id,name,class_name,method_name,method_type,route_name,r.avg_run_time,r.max_run_time,r.min_run_time " + public final static String searchMethodsByName = "select m.id,name,class_name,method_name,method_type,route_name,r.avg_run_time,r.max_run_time,r.min_run_time,r.call_num " +
"from ko_method_node m " + "from ko_method_node m " +
"join ko_method_relation r on m.id = r.target_id " + "join ko_method_relation r on m.id = r.target_id " +
"where m.name like ?"; "where m.name like ?";
public final static String queryChildrenByParent ="select m.id,name,class_name,method_name,method_type,route_name,r.avg_run_time,r.max_run_time,r.min_run_time " + public final static String queryChildrenByParent ="select m.id,name,class_name,method_name,method_type,route_name,r.avg_run_time,r.max_run_time,r.min_run_time,call_num " +
"from ko_method_node m " + "from ko_method_node m " +
"join ko_method_relation r on m.id = r.target_id " + "join ko_method_relation r on m.id = r.target_id " +
"where r.source_id=?"; "where r.source_id=?";

View File

@ -40,6 +40,7 @@ public class KoInitController {
private final String jQueryJsText = getResourceText("kostatic/JQuery.min.js"); private final String jQueryJsText = getResourceText("kostatic/JQuery.min.js");
private final String uiKitIconsJs = getResourceText("kostatic/uikit-icons.js"); private final String uiKitIconsJs = getResourceText("kostatic/uikit-icons.js");
private final String KoTimeUtil = getResourceText("kostatic/util.js"); private final String KoTimeUtil = getResourceText("kostatic/util.js");
private final String commonCss = getResourceText("kostatic/common.css");
@PostMapping("/login") @PostMapping("/login")
@ResponseBody @ResponseBody
@ -146,6 +147,8 @@ public class KoInitController {
line = line.replace("koTimeVersionValue", "'" + KoUtil.getVerssion()+ "'"); line = line.replace("koTimeVersionValue", "'" + KoUtil.getVerssion()+ "'");
}else if (line.indexOf("abbreviationEnableValue") > -1) { }else if (line.indexOf("abbreviationEnableValue") > -1) {
line = line.replace("abbreviationEnableValue", Context.getConfig().getAbbreviationEnable()+""); line = line.replace("abbreviationEnableValue", Context.getConfig().getAbbreviationEnable()+"");
}else if (line.indexOf("commonCss") > -1) {
line = line.replace("commonCss", commonCss);
} }
return line; return line;
} }

View File

@ -127,13 +127,14 @@ public class DataBase implements GraphService {
try { try {
List<Map<String, Object>> query = DataBaseUtil.query(getWriteConnection(), KoSqlConstant.queryMethodRe, new Object[]{sourceMethodNode.getId() + targetMethodNode.getId()}); List<Map<String, Object>> query = DataBaseUtil.query(getWriteConnection(), KoSqlConstant.queryMethodRe, new Object[]{sourceMethodNode.getId() + targetMethodNode.getId()});
if (query.size() > 0) { if (query.size() > 0) {
if (Math.random() < Context.getConfig().getDiscardRate()) { // if (Math.random() < Context.getConfig().getDiscardRate()) {
return null; // return null;
} // }
Map<String, Object> old = query.get(0); Map<String, Object> old = query.get(0);
double oldAvg = (double) old.get("avg_run_time"); double oldAvg = (double) old.get("avg_run_time");
double oldMax = (double) old.get("max_run_time"); double oldMax = (double) old.get("max_run_time");
double oldMin = (double) old.get("min_run_time"); double oldMin = (double) old.get("min_run_time");
int callNum = ((int) old.get("call_num"))+1;
BigDecimal bg = BigDecimal.valueOf((targetMethodNode.getValue() + oldAvg) / 2.0); BigDecimal bg = BigDecimal.valueOf((targetMethodNode.getValue() + oldAvg) / 2.0);
double avg = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); double avg = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
double max = targetMethodNode.getValue() > oldMax ? targetMethodNode.getValue() : oldMax; double max = targetMethodNode.getValue() > oldMax ? targetMethodNode.getValue() : oldMax;
@ -144,6 +145,7 @@ public class DataBase implements GraphService {
avg, avg,
max, max,
min, min,
callNum,
sourceMethodNode.getId() + targetMethodNode.getId() sourceMethodNode.getId() + targetMethodNode.getId()
}; };
DataBaseUtil.update(getWriteConnection(), KoSqlConstant.updateMethodRe, params); DataBaseUtil.update(getWriteConnection(), KoSqlConstant.updateMethodRe, params);
@ -155,7 +157,8 @@ public class DataBase implements GraphService {
targetMethodNode.getId(), targetMethodNode.getId(),
targetMethodNode.getValue(), targetMethodNode.getValue(),
targetMethodNode.getValue(), targetMethodNode.getValue(),
targetMethodNode.getValue() targetMethodNode.getValue(),
1
}; };
DataBaseUtil.insert(getWriteConnection(), KoSqlConstant.addMethodRe, params); DataBaseUtil.insert(getWriteConnection(), KoSqlConstant.addMethodRe, params);
} }
@ -245,6 +248,7 @@ public class DataBase implements GraphService {
rootInfo.setAvgRunTime(methodRelation.getAvgRunTime()); rootInfo.setAvgRunTime(methodRelation.getAvgRunTime());
rootInfo.setMaxRunTime(methodRelation.getMaxRunTime()); rootInfo.setMaxRunTime(methodRelation.getMaxRunTime());
rootInfo.setMinRunTime(methodRelation.getMinRunTime()); rootInfo.setMinRunTime(methodRelation.getMinRunTime());
rootInfo.setCallNum(methodRelation.getCallNum());
List<ExceptionInfo> exceptionInfos = getExceptions(methodId); List<ExceptionInfo> exceptionInfos = getExceptions(methodId);
rootInfo.setExceptionNum(exceptionInfos.size()); rootInfo.setExceptionNum(exceptionInfos.size());
rootInfo.setExceptions(exceptionInfos); rootInfo.setExceptions(exceptionInfos);

View File

@ -117,11 +117,13 @@ public class MemoryBase implements GraphService {
methodRelation.setAvgRunTime(targetMethodNode.getValue()); methodRelation.setAvgRunTime(targetMethodNode.getValue());
methodRelation.setMaxRunTime(targetMethodNode.getValue()); methodRelation.setMaxRunTime(targetMethodNode.getValue());
methodRelation.setMinRunTime(targetMethodNode.getValue()); methodRelation.setMinRunTime(targetMethodNode.getValue());
methodRelation.setCallNum(1);
MethodRelation old = methodRelations.get(methodRelation.getId()); MethodRelation old = methodRelations.get(methodRelation.getId());
if (null == old) { if (null == old) {
methodRelations.put(methodRelation.getId(), methodRelation); methodRelations.put(methodRelation.getId(), methodRelation);
return methodRelation; return methodRelation;
} else { } else {
old.setCallNum(old.getCallNum()+1);
if (Math.random()<Context.getConfig().getDiscardRate()) { if (Math.random()<Context.getConfig().getDiscardRate()) {
return null; return null;
} }
@ -249,6 +251,7 @@ public class MemoryBase implements GraphService {
methodInfo.setAvgRunTime(relation.getAvgRunTime()); methodInfo.setAvgRunTime(relation.getAvgRunTime());
methodInfo.setMaxRunTime(relation.getMaxRunTime()); methodInfo.setMaxRunTime(relation.getMaxRunTime());
methodInfo.setMinRunTime(relation.getMinRunTime()); methodInfo.setMinRunTime(relation.getMinRunTime());
methodInfo.setCallNum(relation.getCallNum());
if (!methodInfos.contains(methodInfo)) { if (!methodInfos.contains(methodInfo)) {
methodInfos.add(methodInfo); methodInfos.add(methodInfo);
} }
@ -287,6 +290,7 @@ public class MemoryBase implements GraphService {
methodInfo.setAvgRunTime(relation.getAvgRunTime()); methodInfo.setAvgRunTime(relation.getAvgRunTime());
methodInfo.setMaxRunTime(relation.getMaxRunTime()); methodInfo.setMaxRunTime(relation.getMaxRunTime());
methodInfo.setMinRunTime(relation.getMinRunTime()); methodInfo.setMinRunTime(relation.getMinRunTime());
methodInfo.setCallNum(relation.getCallNum());
if (!methodInfos.contains(methodInfo)) { if (!methodInfos.contains(methodInfo)) {
methodInfos.add(methodInfo); methodInfos.add(methodInfo);
} }
@ -331,6 +335,7 @@ public class MemoryBase implements GraphService {
methodInfo.setAvgRunTime(methodRelation.getAvgRunTime()); methodInfo.setAvgRunTime(methodRelation.getAvgRunTime());
methodInfo.setMaxRunTime(methodRelation.getMaxRunTime()); methodInfo.setMaxRunTime(methodRelation.getMaxRunTime());
methodInfo.setMinRunTime(methodRelation.getMinRunTime()); methodInfo.setMinRunTime(methodRelation.getMinRunTime());
methodInfo.setCallNum(methodRelation.getCallNum());
List<ExceptionInfo> exceptionInfos = getExceptions(methodNode.getId()); List<ExceptionInfo> exceptionInfos = getExceptions(methodNode.getId());
methodInfo.setExceptionNum(exceptionInfos.size()); methodInfo.setExceptionNum(exceptionInfos.size());
@ -381,6 +386,7 @@ public class MemoryBase implements GraphService {
rootInfo.setAvgRunTime(methodRelation.getAvgRunTime()); rootInfo.setAvgRunTime(methodRelation.getAvgRunTime());
rootInfo.setMaxRunTime(methodRelation.getMaxRunTime()); rootInfo.setMaxRunTime(methodRelation.getMaxRunTime());
rootInfo.setMinRunTime(methodRelation.getMinRunTime()); rootInfo.setMinRunTime(methodRelation.getMinRunTime());
rootInfo.setCallNum(methodRelation.getCallNum());
List<ExceptionInfo> exceptionInfos = getExceptions(methodId); List<ExceptionInfo> exceptionInfos = getExceptions(methodId);
rootInfo.setExceptionNum(exceptionInfos.size()); rootInfo.setExceptionNum(exceptionInfos.size());
rootInfo.setExceptions(exceptionInfos); rootInfo.setExceptions(exceptionInfos);

View File

@ -124,13 +124,16 @@ public class RedisBase implements GraphService {
methodRelation.setAvgRunTime(targetMethodNode.getValue()); methodRelation.setAvgRunTime(targetMethodNode.getValue());
methodRelation.setMaxRunTime(targetMethodNode.getValue()); methodRelation.setMaxRunTime(targetMethodNode.getValue());
methodRelation.setMinRunTime(targetMethodNode.getValue()); methodRelation.setMinRunTime(targetMethodNode.getValue());
methodRelation.setCallNum(1);
String key = methodRelationPre + methodRelation.getId(); String key = methodRelationPre + methodRelation.getId();
MethodRelation old = query(key, MethodRelation.class); MethodRelation old = query(key, MethodRelation.class);
if (null == old) { if (null == old) {
insert(key, methodRelation); insert(key, methodRelation);
return methodRelation; return methodRelation;
} else { } else {
old.setCallNum(old.getCallNum()+1);
if (Math.random()<Context.getConfig().getDiscardRate()) { if (Math.random()<Context.getConfig().getDiscardRate()) {
insert(key, old);
return null; return null;
} }
BigDecimal bg = BigDecimal.valueOf((methodRelation.getAvgRunTime() + old.getAvgRunTime()) / 2.0); BigDecimal bg = BigDecimal.valueOf((methodRelation.getAvgRunTime() + old.getAvgRunTime()) / 2.0);
@ -242,6 +245,7 @@ public class RedisBase implements GraphService {
methodInfo.setAvgRunTime(relation.getAvgRunTime()); methodInfo.setAvgRunTime(relation.getAvgRunTime());
methodInfo.setMaxRunTime(relation.getMaxRunTime()); methodInfo.setMaxRunTime(relation.getMaxRunTime());
methodInfo.setMinRunTime(relation.getMinRunTime()); methodInfo.setMinRunTime(relation.getMinRunTime());
methodInfo.setCallNum(relation.getCallNum());
if (!methodInfos.contains(methodInfo)) { if (!methodInfos.contains(methodInfo)) {
methodInfos.add(methodInfo); methodInfos.add(methodInfo);
} }
@ -288,6 +292,7 @@ public class RedisBase implements GraphService {
methodInfo.setAvgRunTime(relation.getAvgRunTime()); methodInfo.setAvgRunTime(relation.getAvgRunTime());
methodInfo.setMaxRunTime(relation.getMaxRunTime()); methodInfo.setMaxRunTime(relation.getMaxRunTime());
methodInfo.setMinRunTime(relation.getMinRunTime()); methodInfo.setMinRunTime(relation.getMinRunTime());
methodInfo.setCallNum(relation.getCallNum());
if (!methodInfos.contains(methodInfo)) { if (!methodInfos.contains(methodInfo)) {
methodInfos.add(methodInfo); methodInfos.add(methodInfo);
} }
@ -366,7 +371,7 @@ public class RedisBase implements GraphService {
methodInfo.setAvgRunTime(methodRelation.getAvgRunTime()); methodInfo.setAvgRunTime(methodRelation.getAvgRunTime());
methodInfo.setMaxRunTime(methodRelation.getMaxRunTime()); methodInfo.setMaxRunTime(methodRelation.getMaxRunTime());
methodInfo.setMinRunTime(methodRelation.getMinRunTime()); methodInfo.setMinRunTime(methodRelation.getMinRunTime());
methodInfo.setCallNum(methodRelation.getCallNum());
List<ExceptionInfo> exceptionInfos = getExceptions(methodNode.getId()); List<ExceptionInfo> exceptionInfos = getExceptions(methodNode.getId());
methodInfo.setExceptionNum(exceptionInfos.size()); methodInfo.setExceptionNum(exceptionInfos.size());
methodInfo.setExceptions(exceptionInfos); methodInfo.setExceptions(exceptionInfos);
@ -421,6 +426,7 @@ public class RedisBase implements GraphService {
rootInfo.setAvgRunTime(methodRelation.getAvgRunTime()); rootInfo.setAvgRunTime(methodRelation.getAvgRunTime());
rootInfo.setMaxRunTime(methodRelation.getMaxRunTime()); rootInfo.setMaxRunTime(methodRelation.getMaxRunTime());
rootInfo.setMinRunTime(methodRelation.getMinRunTime()); rootInfo.setMinRunTime(methodRelation.getMinRunTime());
rootInfo.setCallNum(methodRelation.getCallNum());
List<ExceptionInfo> exceptionInfos = getExceptions(methodId); List<ExceptionInfo> exceptionInfos = getExceptions(methodId);
rootInfo.setExceptionNum(exceptionInfos.size()); rootInfo.setExceptionNum(exceptionInfos.size());
rootInfo.setExceptions(exceptionInfos); rootInfo.setExceptions(exceptionInfos);

View File

@ -17,6 +17,7 @@ public class MethodInfo implements Comparable<MethodInfo> {
private Double avgRunTime = 0.0; private Double avgRunTime = 0.0;
private Double maxRunTime = 0.0; private Double maxRunTime = 0.0;
private Double minRunTime = 0.0; private Double minRunTime = 0.0;
private Integer callNum = 0;
private MethodType methodType; private MethodType methodType;
private Integer exceptionNum = 0; private Integer exceptionNum = 0;
private List<MethodInfo> children = new ArrayList<>(); private List<MethodInfo> children = new ArrayList<>();
@ -144,6 +145,14 @@ public class MethodInfo implements Comparable<MethodInfo> {
this.children = children; this.children = children;
} }
public Integer getCallNum() {
return callNum;
}
public void setCallNum(Integer callNum) {
this.callNum = callNum;
}
@Override @Override
public String toString() { public String toString() {
return "RunTimeNode{" + return "RunTimeNode{" +

View File

@ -7,6 +7,7 @@ public class MethodRelation {
private Double avgRunTime = 0.0; private Double avgRunTime = 0.0;
private Double maxRunTime = 0.0; private Double maxRunTime = 0.0;
private Double minRunTime = 10000.0; private Double minRunTime = 10000.0;
private Integer callNum = 0;
public String getId() { public String getId() {
return id; return id;
@ -56,5 +57,11 @@ public class MethodRelation {
this.minRunTime = minRunTime; this.minRunTime = minRunTime;
} }
public Integer getCallNum() {
return callNum;
}
public void setCallNum(Integer callNum) {
this.callNum = callNum;
}
} }

View File

@ -17,7 +17,7 @@ public final class KoInvokedHandler implements InvokedHandler {
@Override @Override
public void onInvoked(MethodNode current, MethodNode parent, Parameter[] names, Object[] values) { public void onInvoked(MethodNode current, MethodNode parent, Parameter[] names, Object[] values) {
if (current == null || (current != null && current.getValue() == 0.0)) { if (current == null) {
return; return;
} }
GraphService graphService = GraphService.getInstance(); GraphService graphService = GraphService.getInstance();

View File

@ -0,0 +1,16 @@
.common-li {
color: #333;
font-weight: 400;
font-size: 14px;
}
.common-li-bolder {
font-size: 16px;
font-weight: 500;
}
.common-li-special {
font-size: 14px;
font-weight: 430;
color: #3621a5;
}

View File

@ -42,6 +42,7 @@ tab.summary.sysusage-metric.physical-memory.current-used=此程序占用
tab.interface.search-tip=搜索方法名或者类名... tab.interface.search-tip=搜索方法名或者类名...
tab.interface.interface-list.avg-tip=平均响应 tab.interface.interface-list.avg-tip=平均响应
tab.interface.interface-list.call-num-tip=调用次数
tab.interface.interface-list.show-metric.type=类型 tab.interface.interface-list.show-metric.type=类型
tab.interface.interface-list.show-metric.avg=平均耗时 tab.interface.interface-list.show-metric.avg=平均耗时
tab.interface.interface-list.show-metric.max=最大耗时 tab.interface.interface-list.show-metric.max=最大耗时

View File

@ -42,6 +42,7 @@ tab.summary.sysusage-metric.physical-memory.current-used=ThisUsed
tab.interface.search-tip=search method name or class name... tab.interface.search-tip=search method name or class name...
tab.interface.interface-list.avg-tip=avg tab.interface.interface-list.avg-tip=avg
tab.interface.interface-list.call-num-tip=callNum
tab.interface.interface-list.show-metric.type=type tab.interface.interface-list.show-metric.type=type
tab.interface.interface-list.show-metric.avg=avg time tab.interface.interface-list.show-metric.avg=avg time
tab.interface.interface-list.show-metric.max=max time tab.interface.interface-list.show-metric.max=max time

View File

@ -3,6 +3,7 @@
<title>KoTime</title> <title>KoTime</title>
<style> <style>
UIKitCss UIKitCss
commonCss
</style> </style>
<script> <script>
UIKitJs; UIKitJs;
@ -80,20 +81,25 @@
let avgRunTime = data[i]['avgRunTime']; let avgRunTime = data[i]['avgRunTime'];
let methodType = data[i]['methodType']; let methodType = data[i]['methodType'];
let routeName = data[i]['routeName']; let routeName = data[i]['routeName'];
let callNum = data[i]['callNum'];
let apiId = className + "." + methodName; let apiId = className + "." + methodName;
let color = avgRunTime > globalThreshold ? 'danger' : 'success'; let color = avgRunTime > globalThreshold ? 'danger' : 'success';
if (methodType == 'Controller' && routeName != null && routeName != '') { if (methodType == 'Controller' && routeName != null && routeName != '') {
if (abbreviationEnable) { if (abbreviationEnable) {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\"><span style='font-size: 16px;font-weight: 500;'>" + simName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>"; html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\"><span class='common-li-bolder'>" + simName + "</span>&nbsp(<span class='common-li-special'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
"&nbsp &nbsp<span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
}else { }else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>"; html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\">" + className + "#<span class='common-li-bolder'>" + methodName + "</span>&nbsp(<span class='common-li-special'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
"&nbsp &nbsp<span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
} }
} else { } else {
if (abbreviationEnable) { if (abbreviationEnable) {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\"><span style='font-size: 16px;font-weight: 500;'>" + simName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>"; html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\"><span class='common-li-bolder'>" + simName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
"&nbsp &nbsp<span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
}else { }else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>"; html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\">" + className + "#<span class='common-li-bolder'>" + methodName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: unset' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
"&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
} }
} }
} }
@ -428,20 +434,25 @@
let avgRunTime = data[i]['avgRunTime']; let avgRunTime = data[i]['avgRunTime'];
let methodType = data[i]['methodType']; let methodType = data[i]['methodType'];
let routeName = data[i]['routeName']; let routeName = data[i]['routeName'];
let callNum = data[i]['callNum'];
let apiId = className + "." + methodName; let apiId = className + "." + methodName;
let color = avgRunTime > globalThreshold ? 'danger' : 'success'; let color = avgRunTime > globalThreshold ? 'danger' : 'success';
if (methodType == 'Controller' && routeName != null && routeName != '') { if (methodType == 'Controller' && routeName != null && routeName != '') {
if (abbreviationEnable) { if (abbreviationEnable) {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\"><span style='font-size: 16px;font-weight: 500;'>" + simName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>"; html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\"><span class='common-li-bolder'>" + simName + "</span>&nbsp(<span class='common-li-special'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
"&nbsp &nbsp<span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
}else { }else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>"; html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\">" + className + "#<span class='common-li-bolder'>" + methodName + "</span>&nbsp(<span class='common-li-special'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
"&nbsp &nbsp<span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
} }
} else { } else {
if (abbreviationEnable) { if (abbreviationEnable) {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\"><span style='font-size: 16px;font-weight: 500;'>" + simName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>"; html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\"><span class='common-li-bolder'>" + simName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: unset' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
"&nbsp &nbsp<span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
}else { }else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>"; html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\">" + className + "#<span class='common-li-bolder'>" + methodName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: unset' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
"&nbsp &nbsp<span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
} }
} }
} }
@ -636,7 +647,7 @@
let cpuUsage = thread['cpuUsage']; let cpuUsage = thread['cpuUsage'];
let cpuUsageColor = getCpuUsageColor(cpuUsage); let cpuUsageColor = getCpuUsageColor(cpuUsage);
threadMap[id + ''] = stacks; threadMap[id + ''] = stacks;
html += `<li onclick="showThreadInfo('${id}')" style='color: #333;font-weight: 400;font-size: 14px;'>id=<span style="font-size: 16px;font-weight: 500;">${id}</span>&nbsp; &nbsp;name=${name}&nbsp; &nbsp;class=${classType}&nbsp; &nbsp;<span style="font-size: 10px;background-color: ${cpuUsageColor};" class="uk-label uk-label-success">{{tab.thread.thread-list.cpu-usage}}:${cpuUsage}%</span>&nbsp; &nbsp;<span style='font-size: 10px;background-color: ${colors[state]};' class="uk-label uk-label-success">${state}</span></li>`; html += `<li onclick="showThreadInfo('${id}')" class='common-li'>id=<span style="font-size: 16px;font-weight: 500;">${id}</span>&nbsp; &nbsp;name=${name}&nbsp; &nbsp;class=${classType}&nbsp; &nbsp;<span style="font-size: 10px;background-color: ${cpuUsageColor};" class="uk-label uk-label-success">{{tab.thread.thread-list.cpu-usage}}:${cpuUsage}%</span>&nbsp; &nbsp;<span style='font-size: 10px;background-color: ${colors[state]};' class="uk-label uk-label-success">${state}</span></li>`;
} }
element.innerHTML = html; element.innerHTML = html;
}); });
@ -651,7 +662,7 @@
let methodName = stack['methodName'] let methodName = stack['methodName']
let fileName = stack['fileName'] let fileName = stack['fileName']
let lineNumber = stack['lineNumber'] let lineNumber = stack['lineNumber']
html += `<li style='color: #333;font-weight: 400;font-size: 14px;'>${className}.${methodName}&nbsp; &nbsp;<span style='font-size: 10px;background-color: darkslategray;text-transform: unset' class="uk-label uk-label-success">${fileName}${lineNumber}</span></li>`; html += `<li class='common-li'>${className}.${methodName}&nbsp; &nbsp;<span style='font-size: 10px;background-color: darkslategray;text-transform: unset' class="uk-label uk-label-success">${fileName}${lineNumber}</span></li>`;
} }
let threadDetailDom = getDom('thread-detail'); let threadDetailDom = getDom('thread-detail');

View File

@ -0,0 +1,49 @@
-- spring2 v2.4.7及以上版本
-- spring3 v3.1.0及以上版本
create table ko_method_node
(
id varchar(400) not null primary key comment '主键',
name varchar(400) null comment '类名+方法名',
class_name varchar(400) null comment '类名',
method_name varchar(400) null comment '方法名',
route_name varchar(400) null comment '路由controller才有',
method_type varchar(64) null comment '方法类型'
) comment '方法信息表';
create table ko_method_relation
(
id varchar(400) not null primary key comment '',
source_id varchar(400) null comment '调用方id',
target_id varchar(400) null comment '被调用方id',
call_num int null comment '调用次数',
avg_run_time numeric(10, 2) null comment '平均耗时',
max_run_time numeric(10, 2) null comment '最大耗时',
min_run_time numeric(10, 2) null comment '最小耗时'
) comment '方法调用关系表';
;
create table ko_exception_node
(
id varchar(400) not null primary key comment '主键',
name varchar(400) null comment '异常名',
class_name varchar(400) null comment '类名'
) comment '异常表';
create table ko_exception_relation
(
id varchar(400) not null primary key comment '',
source_id varchar(400) null comment '调用方法id',
target_id varchar(400) null comment '异常id',
location int null comment '异常位置',
message varchar(400) null comment '异常消息'
) comment '异常关系表';
create table ko_param_ana
(
source_id varchar(400) null comment '调用方法id',
params varchar(400) null comment '参数组合,-分隔',
avg_run_time numeric(10, 2) null comment '平均耗时',
max_run_time numeric(10, 2) null comment '最大耗时',
min_run_time numeric(10, 2) null comment '最小耗时'
) comment '参数分析表';