使用命令跟踪一个方法的耗时

在arthas 命令行下输入命令

trace 类全路径 监控的方法

 trace com.redxun.bpm.core.service.BpmInstServiceImpl doStartProcess

 trace 类名全路径 方法名称,看下图当我的方法执行的时候,可以看到每一个步骤的耗时。

 

 

 其他参数

-n 2

这个表示监控两次方法,就停止监控

条件

'#cost >200'

trace com.redxun.bpm.core.controller.BpmInstController startProcess   '#cost >300'

当耗时超过300毫秒显示监控数据信息。

多层级跟踪

trace默认只跟踪一级方法,如果需要多级跟踪,可以按照下面的方法处理。

1.打开一个arthas 窗口

trace com.redxun.bpm.core.controller.BpmInstController startProcess   '#cost >300'

 

这里我们拿到 listenerId 为 11

2.开一个新的arthas 窗口

执行上面方法里面调用的方法

 trace com.redxun.bpm.core.service.BpmInstServiceImpl doStartProcess  --listenerId 11

3.调用第一层的方法

可以观察到调用执行的堆栈信息

 

监控类执行情况

monitor -c 5 com.redxun.bpm.core.service.BpmInstServiceImpl doStartProcess

 

 每隔5秒监控一次

 

posted on 2022-05-11 16:59  自由港  阅读(2296)  评论(0编辑  收藏  举报