查询 span 列表
更新时间:2026-06-26
DescribeSpans
Span列表查询,支持多种过滤条件、排序及分页,返回匹配的Span列表。
API Explorer
去调试
您可以在 API Explorer 中直接运行该接口,免去您计算签名的困扰。运行成功后,API Explorer 可以自动生成 SDK 代码示例。
请求结构
Plain Text
1POST /v1/apm/query?action=DescribeSpans HTTP/1.1
2Host: apm.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "beginDatetime": "20241011T10:10:10Z",
7 "endDatetime": "20241011T10:25:10Z",
8 "filters": [
9 {
10 "key": "service",
11 "op": "=",
12 "value": "mall-gateway"
13 }
14 ],
15 "orderBy": "startTime",
16 "order": "desc",
17 "marker": ""
18}
请求头域
除公共头域外,无其他特殊头域
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| version | String | 是 | URL参数 | API版本号,当前取值为v1 |
| action | String | 是 | URL参数 | API接口名称,当前取值为DescribeSpans |
| beginDatetime | String | 是 | RequestBody参数 | 开始时间,UTC时间 |
| endDatetime | String | 是 | RequestBody参数 | 结束时间,UTC时间 |
| filters | List<Filter> | 否 | RequestBody参数 | 过滤项列表。支持的过滤字段:service(应用名称)、name(span名称)、kind(span类型)、host(实例名称)、duration(响应时间,单位us)、traceId(TraceID)、statusCode(Span状态码)、hasException(是否存在异常)、exception.type(异常类型)、attributes.apm.operation(接口)、attributes.apm.component(请求类型)、slowRequest(慢调用)、slowDBRequest(慢SQL)、attributes.${key}(自定义span属性值)、env(所属环境) |
| orderBy | String | 否 | RequestBody参数 | 排序字段,默认值:startTime |
| order | String | 否 | RequestBody参数 | 排序方式,可选值:asc、desc |
| marker | String | 否 | RequestBody参数 | 翻页游标。请求第一页时填空,请求后续页时使用上一页返回的nextMarker值 |
返回状态码
成功返回200,失败返回见错误码
返回头域
除公共头域外,无其他特殊头域
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| code | String | 状态码 |
| message | String | 错误信息 |
| spans | List<Span> | Span列表 |
| nextMarker | String | 翻页游标,用于填充下一页请求中的marker参数 |
| isTruncated | Boolean | 是否还有下一页,true表示还有下一页,false表示已是最后一页 |
请求示例
Plain Text
1POST /v1/apm/query?action=DescribeSpans HTTP/1.1
2HOST apm.bj.baidubce.com
3Authorization bce-auth-v1/...
4
5{
6 "beginDatetime": "20241011T10:10:10Z",
7 "endDatetime": "20241011T10:25:10Z",
8 "filters": [
9 {
10 "key": "service",
11 "op": "=",
12 "value": "mall-gateway"
13 }
14 ],
15 "orderBy": "startTime",
16 "order": "desc",
17 "marker": ""
18}
响应示例
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 "spans": [
13 {
14 "traceId": "255e69731af9f35845d453d0c321e42e",
15 "spanId": "90c0800ffbf8a363",
16 "parentSpanId": "59568a6558c9aae8",
17 "name": "GET",
18 "service": "frontend-proxy",
19 "start": 1737098708489438,
20 "end": 1737098708492651,
21 "duration": 3213,
22 "host": "192.168.0.1",
23 "statusCode": "STATUS_CODE_OK",
24 "kind": "SPAN_KIND_SERVER",
25 "attributes": {
26 "apm.component": "http",
27 "apm.operation": "GET /images/products/SolarFilter.jpg",
28 "http.response.status_code": 200
29 },
30 "resource": {
31 "host.arch": "arm64",
32 "os.type": "linux"
33 },
34 "events": [
35 {
36 "name": "exception",
37 "timestamp": 1739845445753267500,
38 "attributes": {
39 "exception.type": "com.netflix.HystrixBadRequestException",
40 "exception.message": "Retrieve Nova for vm detail information failed",
41 "exception.stacktrace": "com.netflix.HystrixBadRequestException: Retrieve ..."
42 }
43 }
44 ]
45 }
46 ],
47 "nextMarker": "diVSUvI4/p9d+6xR4/+YQDJ18ojyOP6X",
48 "isTruncated": true
49}
评价此篇文章
