From 3a270759877ed3398054098806922e820f364e5b Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Fri, 25 Jan 2019 11:44:04 +0800 Subject: [PATCH] update trace doc. --- .../arthas/core/command/monitor200/TraceCommand.java | 1 + site/src/site/sphinx/en/trace.md | 10 ++++++++++ site/src/site/sphinx/trace.md | 12 +++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TraceCommand.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TraceCommand.java index ce5861896..e08ca3a35 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TraceCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TraceCommand.java @@ -33,6 +33,7 @@ import java.util.List; " trace *StringUtils isBlank params[0].length==1\n" + " trace *StringUtils isBlank '#cost>100'\n" + " trace -E org\\\\.apache\\\\.commons\\\\.lang\\\\.StringUtils isBlank\n" + + " trace -E com.test.ClassA|org.test.ClassB method1|method2|method3\n" + Constants.WIKI + Constants.WIKI_HOME + "trace") public class TraceCommand extends EnhancerCommand { diff --git a/site/src/site/sphinx/en/trace.md b/site/src/site/sphinx/en/trace.md index 05a112921..b3f089a62 100644 --- a/site/src/site/sphinx/en/trace.md +++ b/site/src/site/sphinx/en/trace.md @@ -86,3 +86,13 @@ Affect(class-cnt:1 , method-cnt:1) cost in 41 ms. * "[min=0.005428ms,max=0.094064ms,total=0.105228ms,count=3] demo:call()" means aggregating all same method calls into one single line. The minimum time cost is `0.005428` ms, the maximum time cost is `0.094064` ms, and the total time cost for all method calls (`3` times in total) to "demo:call()" is `0.105228ms`. If "throws Exception" appears in this line, it means some exceptions have been thrown from this method calls. * The total time cost may not equal to the sum of the time costs each sub method call takes, this is because Arthas instrumented code takes time too. + +#### trace multiple classes or multiple methods + +The trace command will only trace the subcalls in the method to the trace, and will not trace down multiple layers. Because traces are expensive, multi-layer traces can lead to a lot of classes and methods that ultimately have to be traced. + +You can use the regular expression to match multiple classes and methods on the path to achieve a multi-layer trace effect to some extent. + +```bash +Trace -E com.test.ClassA|org.test.ClassB method1|method2|method3 +``` \ No newline at end of file diff --git a/site/src/site/sphinx/trace.md b/site/src/site/sphinx/trace.md index 05ce41a5a..7e0d03201 100644 --- a/site/src/site/sphinx/trace.md +++ b/site/src/site/sphinx/trace.md @@ -86,4 +86,14 @@ Affect(class-cnt:1 , method-cnt:1) cost in 41 ms. - 是不是很眼熟,没错,在 JProfiler 等收费软件中你曾经见识类似的功能,这里你将可以通过命令就能打印出指定调用路径。 友情提醒下,`trace` 在执行的过程中本身是会有一定的性能开销,在统计的报告中并未像 JProfiler 一样预先减去其自身的统计开销。所以这统计出来有些许的不准,渲染路径上调用的类、方法越多,性能偏差越大。但还是能让你看清一些事情的。 - [12.033735ms] 的含义,`12.033735` 的含义是:当前节点在当前步骤的耗时,单位为毫秒 - [0,0,0ms,11]xxx:yyy() [throws Exception],对该方法中相同的方法调用进行了合并,`0,0,0ms,11` 表示方法调用耗时,`min,max,total,count`;`throws Exception` 表明该方法调用中存在异常返回 -- 这里存在一个统计不准确的问题,就是所有方法耗时加起来可能会小于该监测方法的总耗时,这个是由于 Arthas 本身的逻辑会有一定的耗时 \ No newline at end of file +- 这里存在一个统计不准确的问题,就是所有方法耗时加起来可能会小于该监测方法的总耗时,这个是由于 Arthas 本身的逻辑会有一定的耗时 + +#### trace多个类或者多个函数 + +trace命令只会trace匹配到的函数里的子调用,并不会向下trace多层。因为trace是代价比较贵的,多层trace可能会导致最终要trace的类和函数非常多。 + +可以用正则表匹配路径上的多个类和函数,一定程度上达到多层trace的效果。 + +```bash +trace -E com.test.ClassA|org.test.ClassB method1|method2|method3 +``` \ No newline at end of file