查询 LLM trace 详情
更新时间:2026-06-26
DescribeLLMTrace
查询LLM Trace详情,返回指定TraceID的完整调用链信息,包含树形结构的Span数据。
API Explorer
去调试
您可以在 API Explorer 中直接运行该接口,免去您计算签名的困扰。运行成功后,API Explorer 可以自动生成 SDK 代码示例。
请求结构
Plain Text
1POST /v1/apm/query?action=DescribeLLMTrace HTTP/1.1
2Host: apm.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "beginDatetime": "20241011T10:10:10Z",
7 "endDatetime": "20241011T10:25:10Z",
8 "traceId": "255e69731af9f35845d453d0c321e42e",
9 "filters": [
10 {
11 "key": "service",
12 "op": "=",
13 "value": "mall-gateway"
14 }
15 ],
16 "returnHeight": false
17}
请求头域
除公共头域外,无其他特殊头域
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| version | String | 是 | URL参数 | API版本号,当前取值为v1 |
| beginDatetime | String | 是 | RequestBody参数 | 开始时间,UTC时间 |
| endDatetime | String | 是 | RequestBody参数 | 结束时间,UTC时间 |
| 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 |
| tokens | Integer | Trace包含的tokens总数 |
| input | String | Trace LLM输入,可以是任意类型 |
| output | String | Trace LLM输出,可以是任意类型 |
| rootSpans | List<LLMSpan> | 根Span列表,每个Span包含subSpans子Span列表,形成树形结构 |
请求示例
Plain Text
1POST /v1/apm/query?action=DescribeLLMTrace 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 "traceId": "255e69731af9f35845d453d0c321e42e",
9 "filters": [
10 {
11 "key": "service",
12 "op": "=",
13 "value": "mall-gateway"
14 }
15 ],
16 "returnHeight": false
17}
响应示例
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 "tokens": 100,
16 "input": "this is a question",
17 "output": "this is an answer",
18 "rootSpans": [
19 {
20 "traceId": "255e69731af9f35845d453d0c321e42e",
21 "spanId": "90c0800ffbf8a363",
22 "parentSpanId": "59568a6558c9aae8",
23 "name": "GET",
24 "service": "frontend-proxy",
25 "start": 1737098708489438,
26 "end": 1737098708492651,
27 "duration": 3213,
28 "host": "192.168.0.1",
29 "statusCode": "STATUS_CODE_OK",
30 "kind": "SPAN_KIND_SERVER",
31 "input": {
32 "content": "",
33 "contentRef": ["attributes", "traceloop.entity.input", "inputs"]
34 },
35 "inputMessages": [
36 {
37 "role": "user",
38 "content": "",
39 "contentRef": ["attributes", "gen_ai.prompt.0.content"]
40 }
41 ],
42 "output": {
43 "content": "",
44 "contentRef": ["attributes", "traceloop.entity.output", "outputs"]
45 },
46 "outputMessages": [
47 {
48 "role": "assistant",
49 "content": "",
50 "contentRef": ["attributes", "gen_ai.completion.0.content"]
51 }
52 ],
53 "attributes": {
54 "apm.component": "http",
55 "apm.operation": "GET /images/products/SolarFilter.jpg",
56 "gen_ai.kind": "workflow",
57 "gen_ai.response.model": "ernie-4.0-turbo-128k",
58 "llm.usage.total_tokens": 7039,
59 "gen_ai.usage.prompt_tokens": 6988,
60 "gen_ai.usage.completion_tokens": 51
61 },
62 "resource": {
63 "host.arch": "arm64",
64 "os.type": "linux"
65 },
66 "events": [
67 {
68 "name": "exception",
69 "timestamp": 1739845445753267500,
70 "attributes": {
71 "exception.type": "com.netflix.HystrixBadRequestException",
72 "exception.message": "Retrieve Nova for vm detail information failed",
73 "exception.stacktrace": "com.netflix.HystrixBadRequestException: Retrieve..."
74 }
75 }
76 ],
77 "height": 0,
78 "subSpans": [
79 {"spanId": "70f216b0d9d792a4"},
80 {"spanId": "90932073a69edbdf"}
81 ]
82 }
83 ]
84}
评价此篇文章
