处理遥测
http://localhost:{PORT},localhost是本地主机IP:127.0.0.1。
使用遥测 API 订阅后,扩展会自动开始通过遥测侦听器接收来自FunctionGraph的遥测数据。每个 POST 请求正文都包含 Event 对象数组。
订阅事件类型包括三大类:platform、function、extension。
类别 | Event Type | 描述 |
|---|---|---|
平台事件 | platform | 函数的执行情况 |
函数日志 | function | 来自函数代码的日志 |
扩展日志 | extension | 来自扩展代码的日志 |
platform类型事件包括以下几类:
类别 | 子类型 | 含义 | 数据结构 | 示例 |
|---|---|---|---|---|
开始调用事件 | platform.initStart | 表示函数初始化阶段已开始 | Event: Object - name: String =platform.initStart --事件类型 - startTime: String --开始时间 - traceId: String --调用ID | { "name":"platform.initStart ", "startTime": "2023-02-01T00:03:50.000Z ", "traceId": "69be64a7-0233-11e8-82e4-e5d37911193e" } |
platform.start | 表示函数调用阶段已开始 | |||
platform.restoreStart | 表示函数环境还原事件已启动 | |||
调用完成事件 | platform.initRuntimeDone, | 表示函数初始化阶段已完成 | Event: Object - name: String =platform.initRuntimeDone --事件类型 - startTime: String --开始时间 - traceId: String --调用ID - status: String --调用状态 | { "name": " platform.initRuntimeDone", "startTime": "2023-02-01T00:03:50.000Z", "traceId": "69be64a7-0233-11e8-82e4-e5d37911193e", "status":" success ", } |
platform.RuntimeDone | 表示函数调用阶段已完成 | |||
platform.restoreRuntimeDone | 表示函数环境还原事件已完成 | |||
调用报告 | platform.initReport | 包含函数初始化阶段的总体报告 | Event: Object - name: String =platform.initReport | platform.report | platform.restoreReport --事件类型 - startTime: String --开始时间 - traceId: String --调用ID - endTime: String --结束时间 - status: String --调用状态 - metrics: reportMetrics --调用数据 reportMetrics: Object - durationMs: float64 --调用时长 - billingDurationMS: float64 --计费时长 - memoryUsed: float64 --内存使用大小 - memorySize: int --内存大小 - podName: String --pod名 | { "name": " platform.initReport", "startTime": "2023-02-01T00:03:50.000Z", "traceId": "69be64a7-0233-11e8-82e4-e5d37911193e", "endTime":" 2023-02-02T00:03:50.000Z ", "status":" success ", "reportMetrics": { "durationMs": 10.6, "billingDurationMS": 11, "memoryUsed": 23.4, " memorySize ": 128, "podName": pool22-300-128-fusion-64774779-4g77v, } } |
platform.report | 包含函数调用阶段的总体报告 | |||
platform.restoreReport | 包含函数还原事件的总体报告 |
Function类型事件:
类型 | 数据结构 | 示例 |
|---|---|---|
Function | Event: Object - name: String --事件类型 - startTime: String --开始时间 - logs: string --日志内容 | 对于需要采集的日志内容需要在日志中添加[Function],例如:[Function]this is a simple log. { "name": "function", "startTime": "2023-02-01T00:03:50.000Z", "logs": "[Function]this is a simple log." } |
Extension类型事件:
类型 | 数据结构 | 示例 |
|---|---|---|
Extension | Event: Object - name: String --事件类型 - startTime: String --开始时间 - logs: string --日志内容 | 对于需要采集的日志内容需要在日志中添加[Extension],例如:[Extension]this is a simple log. { "name": "extension", "startTime": "2023-02-01T00:03:50.000Z", "logs": "[Extension]this is a simple log." } |

