diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/WatchCommand.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/WatchCommand.java index db3700a50..f0556465f 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/WatchCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/WatchCommand.java @@ -10,6 +10,7 @@ import com.taobao.arthas.core.shell.cli.CompletionUtils; import com.taobao.arthas.core.shell.command.CommandProcess; import com.taobao.arthas.core.util.SearchUtils; import com.taobao.arthas.core.util.matcher.Matcher; +import com.taobao.arthas.core.view.ObjectView; import com.taobao.middleware.cli.annotations.Argument; import com.taobao.middleware.cli.annotations.DefaultValue; import com.taobao.middleware.cli.annotations.Description; @@ -101,7 +102,7 @@ public class WatchCommand extends EnhancerCommand { } @Option(shortName = "x", longName = "expand") - @Description("Expand level of object (1 by default)") + @Description("Expand level of object (1 by default), the max value is " + ObjectView.MAX_DEEP) public void setExpand(Integer expand) { this.expand = expand; } diff --git a/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java b/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java index c170caf1d..bddcdd808 100644 --- a/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java +++ b/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java @@ -20,6 +20,7 @@ import static java.lang.String.format; * Created by vlinux on 15/5/20. */ public class ObjectView implements View { + public static final int MAX_DEEP = 4; private static final Logger logger = LoggerFactory.getLogger(ObjectView.class); private final static int MAX_OBJECT_LENGTH = 10 * 1024 * 1024; // 10M @@ -33,7 +34,7 @@ public class ObjectView implements View { public ObjectView(Object object, int deep, int maxObjectLength) { this.object = object; - this.deep = deep > 4 ? 4 : deep; + this.deep = deep > MAX_DEEP ? MAX_DEEP : deep; this.maxObjectLength = maxObjectLength; } diff --git a/site/src/site/sphinx/en/watch.md b/site/src/site/sphinx/en/watch.md index 483d0dc4a..f034525bc 100644 --- a/site/src/site/sphinx/en/watch.md +++ b/site/src/site/sphinx/en/watch.md @@ -22,7 +22,7 @@ There are four different scenarios for `watch` command, which makes it rather co |[s]|when method exits normally| |[f]|when method exits (either succeed or fail with exceptions)| |[E]|turn on regex matching while the default is wildcard matching| -|[x:]|the depth to print the specified property with default value: 1| +|[x:]|the depth to print the specified property with default value: 1, the max value is 4| F.Y.I 1. any valid OGNL expression as `"{params,returnObj}"` supported @@ -178,7 +178,7 @@ ts=2018-12-03 19:34:19; [cost=0.587833ms] result=@ArrayList[ ``` * `-x`: Expand level of object (1 by default) - +* The max value of `-x` is 4, to prevent the expansion result taking up too much memory. Users can specify the field in the `ognl` expression. #### Use condition expressions to locate specific call ```bash diff --git a/site/src/site/sphinx/watch.md b/site/src/site/sphinx/watch.md index 217c52870..62a75ef68 100644 --- a/site/src/site/sphinx/watch.md +++ b/site/src/site/sphinx/watch.md @@ -22,7 +22,7 @@ watch 的参数比较多,主要是因为它能在 4 个不同的场景观察 |[s]|在**函数返回之后**观察| |[f]|在**函数结束之后**(正常返回和异常返回)观察| |[E]|开启正则表达式匹配,默认为通配符匹配| -|[x:]|指定输出结果的属性遍历深度,默认为 1| +|[x:]|指定输出结果的属性遍历深度,默认为 1,最大值是4| 这里重点要说明的是观察表达式,观察表达式的构成主要由 ognl 表达式组成,所以你可以这样写`"{params,returnObj}"`,只要是一个合法的 ognl 表达式,都能被正常支持。 @@ -178,6 +178,7 @@ ts=2018-12-03 19:34:19; [cost=0.587833ms] result=@ArrayList[ ``` * `-x`表示遍历深度,可以调整来打印具体的参数和结果内容,默认值是1。 +* `-x`最大值是4,防止展开结果占用太多内存。用户可以在`ognl`表达式里指定更具体的field。 #### 条件表达式的例子