使用arthas排查线上问题
目录
Arthas工具使用
命令行一
watch com.example.demo.service.ArthasService testWatch '{params[0].isAddToHome(),returnObj,throwExp}' -n 5 -x 3 -b -s "params[0].getAppId() == '1002'"
结果:
[arthas@3662]$ watch com.example.demo.service.ArthasService testWatch '{params[0].isAddToHome(),returnObj,throwExp}' -n 5 -x 3 -b -s "params[0].getAppId() == '1002'"
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 85 ms, listenerId: 1
method=com.example.demo.service.ArthasService.testWatch location=AtEnter
ts=2025-03-25 22:44:57.384; [cost=0.04001ms] result=@ArrayList[
@Boolean[true],
null,
null,
]
method=com.example.demo.service.ArthasService.testWatch location=AtExit
ts=2025-03-25 22:44:57.390; [cost=1225056.284016ms] result=@ArrayList[
@Boolean[false],
null,
null,
]
命令行二
watch com.example.demo.service.ArthasService testWatch '{params[0],returnObj,throwExp}' -n 5 -x 3 "params[0].getAppId() == '1002'"
结果:
[arthas@3662]$ watch com.example.demo.service.ArthasService testWatch '{params[0],returnObj,throwExp}' -n 5 -x 3 "pPress Q or Ctrl+C to abort.2'"
Affect(class count: 1 , method count: 1) cost in 31 ms, listenerId: 3
method=com.example.demo.service.ArthasService.testWatch location=AtExit
ts=2025-03-25 22:47:03.939; [cost=0.05142ms] result=@ArrayList[
@AppInfo[
appId=@String[1002],
addToHome=@Boolean[false],
],
null,
null,
]
待更新
方法重载 和 多参数条件的监听