查询 trace 详情
更新时间:2026-06-26
DescribeTrace
Trace详情查询,根据TraceID获取完整的调用链路信息,返回树形结构的Span列表。
API Explorer
去调试
您可以在 API Explorer 中直接运行该接口,免去您计算签名的困扰。运行成功后,API Explorer 可以自动生成 SDK 代码示例。
请求结构
Plain Text
1POST /v1/apm/query?action=DescribeTrace HTTP/1.1
2Host: apm.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "spanDatetime": "20241011T10:10:10Z",
7 "traceId": "255e69731af9f35845d453d0c321e42e",
8 "filters": [
9 {
10 "key": "service",
11 "op": "=",
12 "value": "mall-gateway"
13 }
14 ],
15 "returnHeight": false
16}
请求头域
除公共头域外,无其他特殊头域
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| version | String | 是 | URL参数 | API版本号,当前取值为v1 |
| action | String | 是 | URL参数 | API接口名称,当前取值为DescribeTrace |
| spanDatetime | String | 否 | RequestBody参数 | 链路中任一span的时间戳。该字段与beginDatetime/endDatetime必填其一,若填写了spanDatetime,将忽略begin/endDatetime |
| beginDatetime | String | 否 | RequestBody参数 | 开始时间,UTC时间。与spanDatetime必填其一 |
| endDatetime | String | 否 | RequestBody参数 | 结束时间,UTC时间。与spanDatetime必填其一 |
| traceId | String | 是 | RequestBody参数 | TraceID |
| filters | List<Filter> | 否 | RequestBody参数 | 过滤项列表 |
| returnHeight | Boolean | 否 | RequestBody参数 | 是否返回span在瀑布图中的高度,默认值:false |
返回状态码
成功返回200,失败返回见错误码
返回头域
除公共头域外,无其他特殊头域
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| code | String | 状态码 |
| message | String | 错误信息 |
| duration | Integer | Trace耗时,单位:us |
| minStartTime | Integer | Trace开始时间戳,单位:us |
| maxEndTime | Integer | Trace结束时间戳,单位:us |
| rootSpans | List<Span> | 根Span列表,每个Span包含subSpans子Span列表,构成树形结构 |
请求示例
Plain Text
1POST /v1/apm/query?action=DescribeTrace HTTP/1.1
2HOST apm.bj.baidubce.com
3Authorization bce-auth-v1/...
4
5{
6 "spanDatetime": "20241011T10:10:10Z",
7 "traceId": "255e69731af9f35845d453d0c321e42e",
8 "filters": [
9 {
10 "key": "service",
11 "op": "=",
12 "value": "mall-gateway"
13 }
14 ],
15 "returnHeight": false
16}
响应示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: request-id-example
3Date: Wed, 08 Jan 2025 03:25:48 GMT
4Transfer-Encoding: chunked
5Content-Type: application/json;charset=UTF-8
6Server: BWS
7
8{
9 "success": true,
10 "code": "OK",
11 "message": "",
12 "duration": 5155,
13 "minStartTime": 1737179999749000,
14 "maxEndTime": 1737179999754155,
15 "rootSpans": [
16 {
17 "traceId": "255e69731af9f35845d453d0c321e42e",
18 "spanId": "90c0800ffbf8a363",
19 "parentSpanId": "59568a6558c9aae8",
20 "name": "GET",
21 "service": "frontend-proxy",
22 "start": 1737098708489438,
23 "end": 1737098708492651,
24 "duration": 3213,
25 "host": "192.168.0.1",
26 "statusCode": "STATUS_CODE_OK",
27 "kind": "SPAN_KIND_SERVER",
28 "attributes": {
29 "apm.component": "http",
30 "apm.operation": "GET /images/products/SolarFilter.jpg",
31 "http.response.status_code": 200
32 },
33 "resource": {
34 "host.arch": "arm64",
35 "os.type": "linux"
36 },
37 "events": [
38 {
39 "name": "exception",
40 "timestamp": 1739845445753267500,
41 "attributes": {
42 "exception.type": "com.netflix.HystrixBadRequestException",
43 "exception.message": "Retrieve Nova for vm detail information failed",
44 "exception.stacktrace": "com.netflix.HystrixBadRequestException: Retrieve..."
45 }
46 }
47 ],
48 "height": 0,
49 "subSpans": [
50 {"spanId": "70f216b0d9d792a4"},
51 {"spanId": "90932073a69edbdf"}
52 ]
53 }
54 ]
55}
评价此篇文章
