Arthas-watch

作用

方法执行数据观测,能方便的观察到指定方法的调用情况。能观察到的范围为:返回值、抛出异常、入参,通过编写 OGNL 表达式进行对应变量的查看。

参数说明

image-20211031155652550

监控参数与返回值:

watch demo.MathGame primeFactors "{params,returnObj}" -x 2

image-20211031174326592

执行之前监控,没有返回值:

watch demo.MathGame primeFactors "{params,returnObj}" -x 2 -b

image-20211031174541471

执行之前监控方法所在对象的所有属性:

watch demo.MathGame primeFactors "target" -x 2 -b

image-20211031174700385

target 为方法调用对象本身。

执行之前监控方法所在对象的指定的属性:

watch demo.MathGame primeFactors "target" -x 2 -b

image-20211031174946131

watch demo.MathGame primeFactors "target.illegalArgumentCount" -x 2 -b

image-20211031222957105

执行之后与执行之后监控结果:

watch demo.MathGame primeFactors "{params,target,returnObj}" -x 2 -b -s -n 2

image-20211031223235232

  • -n 2:总共执行两次
  • -s:方法后
  • -b:方法前

第一个参数小于 0 的情况:

watch demo.MathGame primeFactors "{params[0],target}" "params[0]<0"

image-20211031223535077

End

posted @ 2021-10-31 22:36  BNTang  阅读(292)  评论(0)    收藏  举报