ezprofiler统计Controller方法的执行时间

ezProfiler是一款用于Spring Boot项目的性能监控工具,通过简单的配置即可监控所有Controller的方法调用情况,包括调用次数、成功率、响应时间等。支持自定义扫描范围、访问路径及权限验证。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载地址:https://github.com/xjs1919/ezprofiler

 

1.安装依赖

下载源码,命令行执行:maven clean install

2.添加依赖

<dependency>
  <groupId>com.github.xjs</groupId>
  <artifactId>ezprofiler-spring-boot-starter</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</dependency>

3.添加配置

@EnableProfiler
@Configuration
public class EzProfilerConfigure {
}

4.项目启动以后,访问浏览器 http://localhost:8080/profiler , 输出结果类似:

{
	"DemoController": [{
		"method": "hello",//方法名
		"uri": "/hello",     //url路径
		"invokeCount": 2,  //总的调用次数
		"okCount": 2,       //总的成功的次数
		"errorCount": 0,   //总的失败的次数
		"minMills": 0,       //最小用时
		"maxMills": 0,      //最大用时
		"avgMills": 0,       //平均用时
		"maxInvokeAt": "2018-08-09 10:28:08", //最大用时发生时间点
		"lastDayCount": 2,  //最近一天总调用次数
		"lastDayOkCount": 2,//最近一天成功次数
		"lastDayErrorCount": 0,//最近一天失败次数
		"lastDayMinMills": 0,//最近一天最小用时
		"lastDayMaxMills": 0,//最近一天最大用时
		"lastDayAvgMills": 0,//最近一天平均用时
		"lastDayMaxInvokeAt": "2018-08-09 10:28:12",//最近一天最大用时发生时间点
		"lastMills": 0,       //上次用时
		"lastInvokeAt": "2018-08-09 10:30:11"//上次调用时间点
	}]
}

其他配置

  1. 默认会统计所有Controller的所有方法,可以在不想被统计的Controller类或者方法上添加@Profiler(false)注解,方法的优先级高于类的优先级
@GetMapping("/world")
@Profiler(false)
public String world() {
  return "world";
}
  1. 默认会给统计接口加上权限验证,默认的用户名:ezprofiler-admin,密码:ezprofiler-admin,可以自定义:
ezprofiler.enableBasic=true
ezprofiler.username=xjs
ezprofiler.password=123456
  1. 默认的profiler的访问路径是/profiler,可以自定义:
ezprofiler.url=/my/profiler

4.可以自定义要扫描的controller的base package,默认是com

ezprofiler.basepackage=com.github.xjs.controller
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值