使用命令跟蹤一個方法的耗時
在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秒監控一次