软件环境
- SpringBoot 3.3.5 官方地址:SpringBoot 3.3.5
- Open JDK17 下载地址:Open JDK17
- Arthas 4.1.3 下载地址:Arthas 4.1.3(可诊断 jdk 8+,如需诊断 jdk 6/7 应用,请参考 Arthas 3.x 文档)
问题背景
生产方法调用存在耗时长,通过日志无法定位耗时长的行(日志打印位置也不合理)。
实操
案例一:Kafka 消费客户端
说明:存在一个业务多个节点串行异步处理。
Step.1: 启动 arthas
java -jar arthas-boot.jar
Step.2: 选择应用(java 进程 id)
图只是个参考,实际是 jdk17。

Step.3: 方法执行链路追踪
trace com.***.crm.channel.dataSyn.service.impl.MssCloudInfoSyncServiceImpl pullDataFinish -n 5 --skipJDKMethod false

说明:限制追踪次数
-n参数指定限制追踪次数。
Step.4: 停止对方法的追踪
# stop com.***.crm.channel.dataSyn.service.impl.MssCloudInfoSyncServiceImpl pullDataFinish -n 5 --skipJDKMethod false
案例二:SAAS 健康度定时任务
Step.1: 启动 arthas
Step.2: 选择应用(java 进程 id)
这里选择的是第二个应用:smet-rpc-service。
[tomcat@[ServerHost] arthas-]$ ls arthas-agent. arthas-client. arthas. . . install-local. logback. arthas-boot. arthas-core. arthas-spy. -service. -profiler lib math-game. [tomcat@[] arthas-]$ ./. script : [] : lib/jvm/jdk--oracle-x64 existing java process, please choose one and input the serial the process, eg : hit . * []: ops-portal. []: [] smet-rpc-service--. []: kafka-map. []: [] smet-rpc-service--. []: org..... []: play... : arthas/arthas- attach execution time... to [] version /app/arthas/arthas-... real 0m2.328s user 0m0.500s sys 0m0.067s success. telnet connecting to arthas server... current timestamp is [] ... to . character is . ,---. ,------. ,--------.,--. ,--. ,---. ,---. / O \ | .--. --. .---- .--- | | | .--. || .-. |-. | | | || |\ \ | | | | | || | | |.- ---- --



