watch

观察方法的返回值和出参

  1. watch com.alibaba.otter.canal.common.utils.DBInfoService getDbUserName "{params,returnObj}" -x 3
  • -b 在方法调用前
  • -x 输出结果的属性遍历深度

方法调用后拦截结果如下:

  1. [arthas@1083]$ watch com.alibaba.otter.canal.common.utils.DBInfoService getDbUserName "{params,returnObj}" -x 3
  2. Press Q or Ctrl+C to abort.
  3. Affect(class-cnt:1 , method-cnt:1) cost in 92 ms.
  4. ts=2020-04-26 11:21:37; [cost=71.184327ms] result=@ArrayList[
  5. @Object[][
  6. @String[47.94.58.144:3306],
  7. ],
  8. null,
  9. ]

观察当前对象中的属性

  1. [arthas@1083]$ watch com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser start 'target.runningInfo' -x 3
  • target 代表当前对象
  • 使用target.field_name访问当前对象的某个属性


  1. ts=2020-04-26 11:48:41; [cost=235.134838ms] result=@AuthenticationInfo[
  2. address=@InetSocketAddress[
  3. holder=@InetSocketAddressHolder[
  4. hostname=null,
  5. addr=@Inet4Address[47.94.58.144/47.94.58.144],
  6. port=@Integer[3306],
  7. ],
  8. serialVersionUID=@Long[5076001401234631237],
  9. serialPersistentFields=@ObjectStreamField[][
  10. @ObjectStreamField[Ljava/lang/String; hostname],
  11. @ObjectStreamField[Ljava/net/InetAddress; addr],
  12. @ObjectStreamField[I port],
  13. ],
  14. FIELDS_OFFSET=@Long[12],
  15. UNSAFE=@Unsafe[
  16. theUnsafe=@Unsafe[sun.misc.Unsafe@2db3c588],
  17. INVALID_FIELD_OFFSET=@Integer[-1],
  18. ARRAY_BOOLEAN_BASE_OFFSET=@Integer[16],
  19. ARRAY_BYTE_BASE_OFFSET=@Integer[16],
  20. ARRAY_SHORT_BASE_OFFSET=@Integer[16],
  21. ARRAY_CHAR_BASE_OFFSET=@Integer[16],
  22. ARRAY_INT_BASE_OFFSET=@Integer[16],
  23. ARRAY_LONG_BASE_OFFSET=@Integer[16],
  24. ARRAY_FLOAT_BASE_OFFSET=@Integer[16],
  25. ARRAY_DOUBLE_BASE_OFFSET=@Integer[16],
  26. ARRAY_OBJECT_BASE_OFFSET=@Integer[16],
  27. ARRAY_BOOLEAN_INDEX_SCALE=@Integer[1],
  28. ARRAY_BYTE_INDEX_SCALE=@Integer[1],
  29. ARRAY_SHORT_INDEX_SCALE=@Integer[2],
  30. ARRAY_CHAR_INDEX_SCALE=@Integer[2],
  31. ARRAY_INT_INDEX_SCALE=@Integer[4],
  32. ARRAY_LONG_INDEX_SCALE=@Integer[8],
  33. ARRAY_FLOAT_INDEX_SCALE=@Integer[4],
  34. ARRAY_DOUBLE_INDEX_SCALE=@Integer[8],
  35. ARRAY_OBJECT_INDEX_SCALE=@Integer[4],
  36. ADDRESS_SIZE=@Integer[8],
  37. ],
  38. serialVersionUID=@Long[5215720748342549866],
  39. ],
  40. username=@String[-----],
  41. password=@String[-------],
  42. defaultDatabaseName=@String[],
  43. pwdPublicKey=@String[retl],
  44. enableDruid=@Boolean[false],
  45. ]

关闭

诊断结束要执行 stop 或将增强过的类执行 reset 命令