Arthas常用的命令(二)--trace

trace 参数

参数名称 参数说明
class-pattern 类名表达式匹配
method-pattern 方法名表达式匹配
condition-express 条件表达式
-E 开启正则表达式匹配,默认为通配符匹配
-n 命令执行次数
#cost 方法执行耗时
-m 指定 Class 最大匹配数量,默认值为 50。

trace 统计方法耗时

格式:

trace 包的路径.类名 方法名

示例:

[arthas@19440]$ trace *.MathGame  run
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 88 ms, listenerId: 15
`---ts=2023-06-08 21:26:27;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@1909752
    `---[0.9027ms] demo.MathGame:run()
        +---[9.72% 0.0877ms ] demo.MathGame:primeFactors() #24
        `---[58.40% 0.5272ms ] demo.MathGame:print() #25

trace 统计最耗时的方法

格式:

trace *.类名 *

*表示任意匹配。

trace根据条件展示耗时

  • 只会展示耗时大于 10ms 的调用
trace demo.MathGame run '#cost > 10'

trace 次数限制

  • 可以用-n参数加上数字,指定捕捉结果的次数
trace demo.MathGame run -n 1

trace 多个类或者多个函数

trace 命令只会 trace 匹配到的函数里的子调用,并不会向下 trace 多层。

可以用正则匹配路径上的多个类和函数,进行多层 trace 。

trace -E com.test.ClassA|org.test.ClassB method1|method2|method3

参考资料:

https://arthas.gitee.io/doc/trace.html

posted on   乐之者v  阅读(4177)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示