java诊断工具Arthas使用
Arthas 是Alibaba开源的Java诊断工具,比较好用,具体可以查看官网 (opens new window)。使用场景:
- 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
- 我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
- 遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
- 线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!
- 是否有一个全局视角来查看系统的运行状况?
- 有什么办法可以监控到JVM的实时运行状态?
- 怎么快速定位应用的热点,生成火焰图?
# 一、IDEA使用
安装Alibaba Cloud Toolkit插件,配置好远程服务器。
# 二、常用功能
控制面板
dashboard
线程
thread
thread -n 10
watch
watch 全路径 方法名 returnObj
watch demo.MathGame primeFactors "{params,returnObj}" -x 2
反编译
jad demo.MathGame
退出
stop
热更新(反编译修改后重新打包失败,还是在本地编译好之后上传服务器吧)
// https://arthas.aliyun.com/doc/retransform.html
// 这种方式不能新增/删除方法或者属性,不能用于正在运行的while(true)中
jad --source-only com.example.demo.arthas.user.UserController > /tmp/UserController.java
mc /tmp/UserController.java -d /tmp
retransform /tmp/com/example/demo/arthas/user/UserController.class
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
上次更新: 2024/01/07, 07:44:52