fix 'no value present'

This commit is contained in:
huoyo 2021-04-20 22:15:14 +08:00
parent 86e2c9afb2
commit da4d5f59ac
6 changed files with 27 additions and 12 deletions

View File

@ -26,15 +26,15 @@ http://huoyo.gitee.io/ko-time/
<dependency>
<groupId>cn.langpy</groupId>
<artifactId>ko-time</artifactId>
<version>1.6</version>
<version>1.7</version>
</dependency>
```
```
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-${freemarker或者thymeleaf任选一个}</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-${freemarker或者thymeleaf任选一个}</artifactId>
</dependency>
```
2. 配置信息
@ -44,10 +44,12 @@ spring.profiles.active=koTime
koTime.log.enable=false # 是否开启控制输出非必填默认false
koTime.log.language=chinese # 控制台输出语言english/chinese非必填默认chinese
koTime.time.threshold=800.0 # 时间阈值用于前端展示大于阈值显示红色小于阈值显示绿色非必填默认800
koTime.pointcut=execution(* com.huoyo..*.*(..)) 需要监测的切面范围参考aop的@pointcut v1.4开始加入的功能用来替代下面的步骤3
koTime.pointcut=execution(* com.huoyo.demo.controller.*(..)) || execution(* com.huoyo.demo.service.*(..)) 需要监测的切面范围比如监测controller层和service层参考aop的@pointcut v1.4开始加入的功能用来替代下面的步骤3
koTime.ui.template=thymeleaf 前端页面模板默认为freemarker可选thymeleaf 与引入的pom依赖对应
```
`注意暂不支持mybatis的mapper监测`
3. 新建一个类实现ComputeTimeHandlerInterface并在 @Pointcut 写入 需要监测的范围
@ -118,6 +120,8 @@ public class RunTimeHandler implements ComputeTimeHandlerInterface {
> V1.6兼容thymeleaf
> V1.7修复未调用接口时No value present异常
#### 特别说明
1.本项目使用java8开发其他版本未曾试验如有什么bug还请告知
@ -132,4 +136,6 @@ public class RunTimeHandler implements ComputeTimeHandlerInterface {
</dependency>
```
3.项目使用@Aspect注解,未引入 aop相关包的自行引入如aspectj或者spring-boot-starter-aop

View File

@ -6,7 +6,7 @@
<groupId>cn.langpy</groupId>
<artifactId>ko-time</artifactId>
<version>1.6</version>
<version>1.7</version>
<name>koTime</name>
<description>koTime</description>
<licenses>

View File

@ -6,9 +6,9 @@ public class SystemStatistic {
private Double avgRunTime = 0.0;
private Double maxRunTime = 0.0;
private Double minRunTime = 0.0;
private Integer totalNum;
private Integer delayNum;
private Integer normalNum;
private Integer totalNum = 0 ;
private Integer delayNum = 0;
private Integer normalNum = 0;
public String getName() {
return name;

View File

@ -66,8 +66,11 @@ public class RunTimeNodeService {
}
public static SystemStatistic getRunStatistic() {
List<RunTimeNode> controllerApis = GraphMap.get(MethodType.Controller);
SystemStatistic systemStatistic = new SystemStatistic();
List<RunTimeNode> controllerApis = GraphMap.get(MethodType.Controller);
if (null==controllerApis || controllerApis.size()==0 ) {
return systemStatistic;
}
int delayNum = (int)controllerApis.stream().filter(controllerApi -> controllerApi.getAvgRunTime() >= Context.getConfig().getTimeThreshold()).count();
systemStatistic.setDelayNum(delayNum);
int normalNum = (int)controllerApis.stream().filter(controllerApi -> controllerApi.getAvgRunTime() < Context.getConfig().getTimeThreshold()).count();

View File

@ -60,6 +60,9 @@
<div class="code">最小响应ms</div>
</li>
</ul>
<ul>
<blockquote class="layui-elem-quote">接口根据调用情况统计,未调用的接口无法被统计到,请先调用接口</blockquote>
</ul>
</div>
<div class="layui-tab-item">
@ -127,7 +130,7 @@
echarts.util.each(data.children, function (datum, index) {
index % 2 === 0 && (datum.collapsed = true);
});
myChart.setOption(option = getOption(data));
myChart.setOption(option = getOption(data,threshold));
});
}

View File

@ -66,6 +66,9 @@
<div class="code">最小响应ms</div>
</li>
</ul>
<ul>
<blockquote class="layui-elem-quote">接口根据调用情况统计,未调用的接口无法被统计到,请先调用接口</blockquote>
</ul>
</div>
<div class="layui-tab-item">