1
比如像 vmtool 命令,如果返回对象没有 get/set 函数,那么很容易就返回一个 {}
。 不能实际查看到应用的 field 等信息。
考虑让HTTP API的行为和 terminal执行命令一致。
比如像 vmtool 命令,如果返回对象没有 get/set 函数,那么很容易就返回一个 {}
。 不能实际查看到应用的 field 等信息。
考虑让HTTP API的行为和 terminal执行命令一致。
嗨@hengyunabc,
此提交破坏了 API Rest 拉取结果,现在始终以字符串形式返回值:
例如,执行:
{
"action":"async_exec",
"command": "watch demo.MathGame primeFactors \"{params, returnObj, throwExp}\" -x 3",
"consumerId": "d18fa78cee4b42a9949e8fd5cac870bb_1",
"sessionId": "57885147-9026-472a-b0dd-99f4ca8ae3ea"
}
有一个“pull_results”操作的示例:
{
"accessPoint": "AtExceptionExit",
"className": "demo.MathGame",
"cost": 0.107455,
"jobId": 1,
"methodName": "primeFactors",
"sizeLimit": 10485760,
"ts": "2022-10-14 17:52:05",
"type": "watch",
"value": "@ArrayList[\n @Object[][\n @Integer[-68719],\n ],\n null,\n java.lang.IllegalArgumentException: number is: -68719, need >= 2\n\tat demo.MathGame.primeFactors(MathGame.java:46)\n\tat demo.MathGame.run(MathGame.java:24)\n\tat demo.MathGame.main(Unknown Source)\n,\n]"
}
在 3.6.4 及以下版本中,“value”是一个数组。
我应该为此创建一个错误问题吗?有办法再次扩大价值吗?
@ismadirolas
将来,也许用户可以为每个http命令设置返回格式。但目前这个配置是全局的。您可以执行options json-format true
.
https://arthas.aliyun.com/en/doc/options.html#view-all-options
我目前使用的版本是3.6.5版本,但是开启options json-format true.后,返回的结果还是{}对象
。。 json当然有可能是 {}
,应该设置为 false。
另外一个实现方案,以树方式展开对象,包含每个对象的属性,便于调用方解析处理:https://github.com/alibaba/arthas/pull/1531
Arthas console:
[arthas@6716]$ watch sample.mybatis.controller.SampleController getHotel -x 3 -n 1
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 36 ms, listenerId: 2
method=sample.mybatis.controller.SampleController.getHotel location=AtExit
ts=2022-12-18 13:48:04; [cost=0.5955ms] result=@ArrayList[
@Object[][
@Integer[1],
],
@SampleController[
cityDao=@CityDao[
sqlSession=@SqlSessionTemplate[org.mybatis.spring.SqlSessionTemplate@15cafec7],
],
cache=@Collections$SynchronizedRandomAccessList[isEmpty=true;size=0],
],
@Hotel[
serialVersionUID=@Long[1],
city=@Long[1],
name=@String[Conrad Treasury Place],
address=@String[William & George Streets],
zip=@String[4001],
],
]
3.6.7 版本的HTTP API结果:
{
"accessPoint": "AtExit",
"className": "sample.mybatis.controller.SampleController",
"cost": 0.6066,
"jobId": 3,
"methodName": "getHotel",
"sizeLimit": 10485760,
"ts": "2022-12-18 13:41:32",
"type": "watch",
"value": "@ArrayList[\n @Object[][\n @Integer[1],\n ],\n @SampleController[\n cityDao=@CityDao[\n sqlSession=@SqlSessionTemplate[org.mybatis.spring.SqlSessionTemplate@4febb875],\n ],\n hotelMapper=@$Proxy64[\n random=@Random[\n cache=@SynchronizedRandomAccessList[isEmpty=true;size=0],\n ],\n @Hotel[\n serialVersionUID=@Long[1],\n city=@Long[1],\n name=@String[Conrad Treasury Place],\n address=@String[William & George Streets],\n zip=@String[4001],\n ],\n]"
}
channel-server 分支 HTTP API 结果, 每个展开的对象包含( type, name, value/fields/size等属性):
{
"accessPoint": "AtExit",
"className": "sample.mybatis.controller.SampleController",
"cost": 41.8159,
"expand": 3,
"jobId": 1,
"methodName": "getHotel",
"sizeLimit": 500,
"ts": "2022-12-18 13:45:22",
"type": "watch",
"value": {
"size": 3,
"type": "java.util.ArrayList",
"value": [
{
"size": 1,
"type": "Object[]",
"value": [
{
"type": "java.lang.Integer",
"value": 1
}
]
},
{
"fields": [
{
"fields": [
{
"name": "sqlSession",
"type": "org.mybatis.spring.SqlSessionTemplate",
"value": "org.mybatis.spring.SqlSessionTemplate@15cafec7"
}
],
"name": "cityDao",
"type": "sample.mybatis.dao.CityDao"
},
{
"name": "cache",
"size": 0,
"type": "java.util.Collections$SynchronizedRandomAccessList"
}
],
"type": "sample.mybatis.controller.SampleController"
},
{
"fields": [
{
"name": "serialVersionUID",
"type": "java.lang.Long",
"value": 1
},
{
"name": "city",
"type": "java.lang.Long",
"value": 1
},
{
"name": "name",
"type": "java.lang.String",
"value": "Conrad Treasury Place"
},
{
"name": "address",
"type": "java.lang.String",
"value": "William & George Streets"
},
{
"name": "zip",
"type": "java.lang.String",
"value": "4001"
}
],
"type": "sample.mybatis.domain.Hotel"
}
]
}
}