@blueking/open-telemetry 0.0.32 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -19
- package/dist/bk-rum.global.js +2 -2
- package/dist/bk-rum.global.js.map +1 -1
- package/dist/core/plugin.d.ts +3 -0
- package/dist/index.js +507 -356
- package/dist/index.js.map +1 -1
- package/dist/plugins/resource.d.ts +11 -0
- package/dist/plugins/web-vitals.d.ts +1 -1
- package/dist/schema/attributes.d.ts +19 -0
- package/dist/schema/span.d.ts +10 -0
- package/package.json +1 -1
- package/skills/bk-rum-otele/SKILL.md +1 -1
- package/skills/bk-rum-otele/evals/evals.json +1 -1
- package/skills/bk-rum-otele/references/actions.md +3 -3
- package/skills/bk-rum-otele/references/api.md +3 -3
- package/skills/bk-rum-otele/references/architecture.md +2 -2
- package/skills/bk-rum-otele/references/blank-screen.md +2 -2
- package/skills/bk-rum-otele/references/capabilities.md +17 -17
- package/skills/bk-rum-otele/references/configuration.md +1 -1
- package/skills/bk-rum-otele/references/data-model.md +3 -3
- package/skills/bk-rum-otele/references/errors-security.md +4 -4
- package/skills/bk-rum-otele/references/getting-started.md +3 -2
- package/skills/bk-rum-otele/references/network.md +5 -5
- package/skills/bk-rum-otele/references/performance.md +2 -2
- package/skills/bk-rum-otele/references/session-context.md +3 -3
- package/skills/bk-rum-otele/references/span-protocol.md +333 -239
- package/skills/bk-rum-otele/references/telemetry-reference.md +36 -33
- package/skills/bk-rum-otele/references/transport-sampling.md +2 -2
- package/skills/bk-rum-otele/references/troubleshooting.md +3 -3
- package/skills/bk-rum-otele/references/views-routing.md +4 -4
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
原则:
|
|
21
21
|
|
|
22
22
|
- 浏览器 SDK 只上报原始 RUM Span(OTLP/HTTP JSON Trace),不创建 Metric 或 Log Provider。
|
|
23
|
-
- Web Vitals 由 SDK 以 `
|
|
23
|
+
- Web Vitals 由 SDK 以 `span_type=vital` 的 Span 上报(`vital.metric` = `cls` / `fcp` / `inp` / `lcp` / `ttfb`);分位数和跨会话聚合由接收端派生。
|
|
24
24
|
- 控制字段规模:只约定当前实现真正使用的字段;未上报字段不要当作采集端契约。
|
|
25
25
|
|
|
26
26
|
## 0x01 用户真实监控模型
|
|
@@ -42,15 +42,15 @@ Session
|
|
|
42
42
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
43
43
|
| ---------------- | -------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
|
|
44
44
|
| `time` |  | str | 数据上报时间(毫秒时间戳字符串) | -- |
|
|
45
|
-
| `app_name` |  | str |
|
|
45
|
+
| `app_name` |  | str | 应用 | -- |
|
|
46
46
|
| `bk_biz_id` |  | str | 业务 ID | -- |
|
|
47
47
|
| `trace_id` |  | str | Trace ID | -- |
|
|
48
|
-
| `trace_state` |  | str | Trace
|
|
49
|
-
| `span_name`
|
|
48
|
+
| `trace_state` |  | str | Trace 扩展信息 | -- |
|
|
49
|
+
| `span_name` *[1]* |  | str | 可读的低基数 Span 名称 | 由 SDK 根据 `span_type` 和领域字段生成。 |
|
|
50
50
|
| `span_id` |  | str | Span ID | -- |
|
|
51
51
|
| `parent_span_id` |  | str | 父 Span ID | -- |
|
|
52
52
|
| `status` |  | Status | Span 执行状态 | 包含 `code` 和 `message`。 |
|
|
53
|
-
| `kind` |  | enum | [
|
|
53
|
+
| `kind` |  | enum | [调用类型](https://opentelemetry.io/zh/docs/concepts/signals/traces/#span-kind) | 枚举值:<br>- 未定义:0<br>- 内部调用:1<br>- 同步被调:2<br>- 同步主调:3<br>- 异步主调:4<br>- 异步被调:5 |
|
|
54
54
|
| `resource` |  | object | 资源信息 | 服务、环境、SDK 等描述信息。 |
|
|
55
55
|
| `events` |  | Event[] | 事件列表 | 异常详情和 Long Task 脚本明细通过 Span Event 承载。 |
|
|
56
56
|
| `links` |  | Link[] | [Span 链接](https://opentelemetry.io/docs/concepts/signals/traces/#span-links) | 链接的存在是为了 Span 同其他 Span 建立关联,从而表明存在因果关系。 |
|
|
@@ -59,21 +59,37 @@ Session
|
|
|
59
59
|
| `end_time` |  | int | 结束时间(微秒) | 同上,对应 `endTimeUnixNano`。 |
|
|
60
60
|
| `elapsed_time` |  | int | 耗时(微秒) | 后端由起止时间相减;浏览器 SDK 不单独上报该 Attribute。 |
|
|
61
61
|
|
|
62
|
+
**[1] `span_name`**:
|
|
63
|
+
|
|
64
|
+
| `attributes.span_type` | 生成规则 | 示例 |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `session` | `session.<attributes.session.phase>` | `session.start` |
|
|
67
|
+
| `view` | `attributes.view.name` | `订单详情` |
|
|
68
|
+
| `resource` | `<attributes.http.request.method> <attributes.url.template>` | `GET /api/orders/:id` |
|
|
69
|
+
| `action` | `attributes.action.name` | `click 提交订单` |
|
|
70
|
+
| `error` | 异常类型;白屏和 CSP 使用稳定分类 | `TypeError`、`blank_screen.empty_viewport`、`csp.script-src-elem` |
|
|
71
|
+
| `vital` | 大写的 `attributes.vital.metric` | `LCP` |
|
|
72
|
+
| `long_task` | `attributes.long_task.entry_type` | `long-animation-frame` |
|
|
73
|
+
| `websocket` | `websocket.<attributes.websocket.phase>` | `websocket.connect` |
|
|
74
|
+
| `custom` | `custom.<name>` | `custom.checkout_success` |
|
|
75
|
+
|
|
76
|
+
名称不包含 ID、完整 URL、错误消息、时间戳或数值。业务传入的 View、Action 和 Custom 名称必须保持稳定。
|
|
77
|
+
|
|
62
78
|
### b. Resource
|
|
63
79
|
|
|
64
80
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
65
81
|
| ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ------ | ----------- | ---------------------------------------------- |
|
|
66
|
-
| `resource.service.name` |  | str |
|
|
82
|
+
| `resource.service.name` |  | str | 服务 | -- |
|
|
67
83
|
| `resource.service.version` |  | str | 版本 | -- |
|
|
68
84
|
| [`resource.deployment.environment.name`](https://opentelemetry.io/docs/specs/semconv/resource/deployment-environment/) |  | str | 环境 | 如 `development`、`production`、`staging`、`test`。 |
|
|
69
|
-
| `resource.session.sample_rate` |  | number |
|
|
85
|
+
| `resource.session.sample_rate` |  | number | 会话采样率 | 取值范围为 `0`~`1`。 |
|
|
70
86
|
| `resource.telemetry.sdk.version` |  | str | SDK 版本 | -- |
|
|
71
|
-
| [`resource.telemetry.sdk.language`](https://opentelemetry.io/docs/specs/semconv/resource/#telemetry-sdk) |  | enum | 语言 | `webjs`。 |
|
|
87
|
+
| [`resource.telemetry.sdk.language`](https://opentelemetry.io/docs/specs/semconv/resource/#telemetry-sdk) |  | enum | SDK 语言 | `webjs`。 |
|
|
72
88
|
| `resource.telemetry.sdk.name` *[1]* |  | str | SDK 名称 | -- |
|
|
73
89
|
| `resource.device.type` |  | enum | 设备类型 | 当前仅为 `desktop`、`mobile`。 |
|
|
74
|
-
| `resource.user_agent.name` |  | str |
|
|
75
|
-
| `resource.user_agent.version` |  | str |
|
|
76
|
-
| `resource.user_agent.os.name` |  | str |
|
|
90
|
+
| `resource.user_agent.name` |  | str | 浏览器 | 通常指的是浏览器的名称,如 `Chrome`、`Edge`。 |
|
|
91
|
+
| `resource.user_agent.version` |  | str | 浏览器版本 | 通常指的是浏览器的名称,如 `149`、`151`。 |
|
|
92
|
+
| `resource.user_agent.os.name` |  | str | 操作系统 | 如 `macOS`、`Windows`、`Android`。 |
|
|
77
93
|
|
|
78
94
|
**[1] `resource.telemetry.sdk.name`**:当前浏览器 SDK 固定为 `blueking`。Aegis 等其他生产端可使用各自名称,不要把 npm 包名 `@blueking/open-telemetry` 当作该字段值。
|
|
79
95
|
|
|
@@ -88,7 +104,7 @@ Session
|
|
|
88
104
|
|
|
89
105
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
90
106
|
| ----------------------------------------------------------------------- | ---------------------------------------------------------- | ------ | ------------- | -------------------- |
|
|
91
|
-
| `events[].name` *[1]* |  | str |
|
|
107
|
+
| `events[].name` *[1]* |  | str | 事件 | |
|
|
92
108
|
| `events[].timestamp` |  | int | 事件发生时间 | SDK 传输为 OTLP Event UnixNano;后端可转为微秒。 |
|
|
93
109
|
| `events[].attributes.exception.type` |  | str | 异常类型 | 如 `TypeError`。 |
|
|
94
110
|
| `events[].attributes.exception.message` |  | str | 异常消息 | 如 `Failed to fetch`。 |
|
|
@@ -96,14 +112,14 @@ Session
|
|
|
96
112
|
| `events[].attributes.long_task.script.duration` |  | number | 脚本耗时(ms) | |
|
|
97
113
|
| `events[].attributes.long_task.script.execution_start` |  | number | 脚本执行开始时间(ms) | |
|
|
98
114
|
| `events[].attributes.long_task.script.forced_style_and_layout_duration` |  | number | 强制样式与布局耗时(ms) | |
|
|
99
|
-
| `events[].attributes.long_task.script.pause_duration` |  | number |
|
|
115
|
+
| `events[].attributes.long_task.script.pause_duration` |  | number | 脚本暂停耗时(ms) | |
|
|
100
116
|
| `events[].attributes.long_task.script.source_char_position` |  | number | 源码字符位置 | |
|
|
101
117
|
| `events[].attributes.long_task.script.start_time` |  | number | 脚本开始时间(ms) | |
|
|
102
|
-
| `events[].attributes.long_task.script.invoker` |  | str |
|
|
103
|
-
| `events[].attributes.long_task.script.invoker_type` |  | str |
|
|
104
|
-
| `events[].attributes.long_task.script.source_function_name` |  | str |
|
|
118
|
+
| `events[].attributes.long_task.script.invoker` |  | str | 脚本触发来源 | |
|
|
119
|
+
| `events[].attributes.long_task.script.invoker_type` |  | str | 脚本触发类型 | |
|
|
120
|
+
| `events[].attributes.long_task.script.source_function_name` |  | str | 脚本函数名 | |
|
|
105
121
|
| `events[].attributes.long_task.script.source_url` |  | str | 已脱敏的脚本 URL | |
|
|
106
|
-
| `events[].attributes.long_task.script.window_attribution` |  | str |
|
|
122
|
+
| `events[].attributes.long_task.script.window_attribution` |  | str | 脚本窗口关系 | |
|
|
107
123
|
|
|
108
124
|
**[1] `events[].name`**:「异常」需将事件名固定为 `exception`。
|
|
109
125
|
|
|
@@ -126,8 +142,8 @@ Session
|
|
|
126
142
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
127
143
|
| ---------------------------- | ---------------------------------------------------------- | ---- | ------- | ---------------------------------------------- |
|
|
128
144
|
| `attributes.user.id` |  | str | 用户 ID | -- |
|
|
129
|
-
| `attributes.span_type` *[1]* |  | enum |
|
|
130
|
-
| `attributes.outcome.type` |  | enum | 执行结果 | `success`、`warning
|
|
145
|
+
| `attributes.span_type` *[1]* |  | enum | 事件类型 | -- |
|
|
146
|
+
| `attributes.outcome.type` |  | enum | 执行结果 | `success`、`warning`(警告)、`error`、`timeout`、`abort`。 |
|
|
131
147
|
|
|
132
148
|
|
|
133
149
|
**[1] `attributes.span_type`**:
|
|
@@ -138,9 +154,9 @@ Session
|
|
|
138
154
|
| `view` | 页面首次加载或路由视图生命周期。 |
|
|
139
155
|
| `resource` | 静态资源、Fetch 或 XHR 请求。 |
|
|
140
156
|
| `error` | 浏览器错误、白屏或 CSP 违规。 |
|
|
141
|
-
| `vital` | Web
|
|
157
|
+
| `vital` | Web 性能指标。 |
|
|
142
158
|
| `long_task` | Long Task 或长动画帧。 |
|
|
143
|
-
| `action` |
|
|
159
|
+
| `action` | 用户操作或主动上报的 Action。 |
|
|
144
160
|
| `websocket` | WebSocket 生命周期事件。 |
|
|
145
161
|
| `custom` | 主动上报的自定义事件。 |
|
|
146
162
|
|
|
@@ -151,7 +167,7 @@ Session
|
|
|
151
167
|
| ------------------------------- | ----------------------------------------------------------- | ------- | ---------- | -------------------------------------------------------------------- |
|
|
152
168
|
| `attributes.error.message` |  | str | 错误信息 | -- |
|
|
153
169
|
| `attributes.error.handled` |  | boolean | 错误是否被捕获 | -- |
|
|
154
|
-
| `attributes.error.source` |  | str | 错误来源 | 枚举值:<br/>- window.error
|
|
170
|
+
| `attributes.error.source` |  | str | 错误来源 | 枚举值:<br/>- window.error(脚本错误,固定值)<br/>- resource(资源加载错误)<br/>- unhandledrejection(未处理的 Promise 异常) |
|
|
155
171
|
| `attributes.code.column` |  | int | 代码列号 | |
|
|
156
172
|
| `attributes.code.filepath` |  | str | 代码文件路径 | |
|
|
157
173
|
| `attributes.code.lineno` |  | int | 代码行号 | |
|
|
@@ -162,8 +178,8 @@ Session
|
|
|
162
178
|
| ------------------------------------ | ---------------------------------------------------------- | --- | ------- | ---------------------------- |
|
|
163
179
|
| `attributes.browser.screen.height` |  | int | 屏幕尺寸的高度 | Aegis 使用 `sr = 1728 * 1117`。 |
|
|
164
180
|
| `attributes.browser.screen.width` |  | int | 屏幕尺寸的宽度 | -- |
|
|
165
|
-
| `attributes.browser.viewport.height` |  | int |
|
|
166
|
-
| `attributes.browser.viewport.width` |  | int |
|
|
181
|
+
| `attributes.browser.viewport.height` |  | int | 可视区域高度 | Aegis 使用 `vp = 576 * 918`。 |
|
|
182
|
+
| `attributes.browser.viewport.width` |  | int | 可视区域宽度 | -- |
|
|
167
183
|
|
|
168
184
|
### d. [device](https://opentelemetry.io/docs/specs/semconv/registry/attributes/device/)
|
|
169
185
|
|
|
@@ -175,10 +191,10 @@ Session
|
|
|
175
191
|
|
|
176
192
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
177
193
|
| ------------------------------------ | -------------------------------------------------------------- | ---- | ------- | ----------------------------------------------------------- |
|
|
178
|
-
| `attributes.network.connection.type` |  | enum |
|
|
179
|
-
| `attributes.network.effective_type` |  | str |
|
|
180
|
-
| `attributes.network.status` |  | enum |
|
|
181
|
-
| `attributes.network.protocol.name` |  | enum |
|
|
194
|
+
| `attributes.network.connection.type` |  | enum | 网络连接类型 | 直接使用浏览器 `navigator.connection.type` 的原始值;字段不存在时不上报。 |
|
|
195
|
+
| `attributes.network.effective_type` |  | str | 网络质量 | -- |
|
|
196
|
+
| `attributes.network.status` |  | enum | 网络状态 | `connected`、`not_connected`。 |
|
|
197
|
+
| `attributes.network.protocol.name` |  | enum | 应用层协议 | 仅 WebSocket Span 上报,固定为 `websocket`;HTTP Resource Span 不上报。 |
|
|
182
198
|
|
|
183
199
|
**[1] `attributes.network.connection.type`**:表示设备当前使用的物理网络连接方式。SDK 直接上报
|
|
184
200
|
[`navigator.connection.type`](https://wicg.github.io/netinfo/#connectiontype-enum);浏览器不支持该 API
|
|
@@ -203,19 +219,19 @@ Aegis 将「连接类型」「网络质量」整合成 `netType`(`wifi`、`wir
|
|
|
203
219
|
|
|
204
220
|
| 值 | 描述 | 备注 |
|
|
205
221
|
| --------- | ---- | -------------------------- |
|
|
206
|
-
| `slow-2g` |
|
|
207
|
-
| `2g` |
|
|
208
|
-
| `3g` |
|
|
209
|
-
| `4g` |
|
|
222
|
+
| `slow-2g` | 极慢 | 页面和图片加载非常慢,通常只能满足少量文本传输。 |
|
|
223
|
+
| `2g` | 较慢 | 简单页面可以打开,图片、脚本和接口请求可能明显缓慢。 |
|
|
224
|
+
| `3g` | 中等 | 普通网页基本可用,但大资源和复杂页面仍可能等待。 |
|
|
225
|
+
| `4g` | 较快 | 延迟和带宽表现较好,适合大多数 Web 应用。 |
|
|
210
226
|
|
|
211
227
|
### f. session
|
|
212
228
|
|
|
213
229
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
214
230
|
| ------------------------------------- | ----------------------------------------------------------- | ------- | -------- | ----------------------------------------------- |
|
|
215
|
-
| `attributes.session.has_replay` |  | boolean |
|
|
231
|
+
| `attributes.session.has_replay` |  | boolean | 有无回放 | -- |
|
|
216
232
|
| `attributes.session.id` |  | str | 会话 ID | -- |
|
|
217
233
|
| `attributes.session.type` |  | enum | 会话类型 | 当前固定为 `user`。 |
|
|
218
|
-
| `attributes.session.phase` *[1]* |  | enum |
|
|
234
|
+
| `attributes.session.phase` *[1]* |  | enum | 会话阶段 | -- |
|
|
219
235
|
|
|
220
236
|
**[1] `attributes.session.phase`**:
|
|
221
237
|
|
|
@@ -229,36 +245,36 @@ Aegis 将「连接类型」「网络质量」整合成 `netType`(`wifi`、`wir
|
|
|
229
245
|
|
|
230
246
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
231
247
|
| ------------------------------------- | -------------------------------------------------------------- | ------ | ----------------------- | --------------------------------------------- |
|
|
232
|
-
| `attributes.view.id` |  | str |
|
|
233
|
-
| `attributes.view.name` *[1]* |  | str |
|
|
234
|
-
| `attributes.view.loading_type` *[2]* |  | str |
|
|
235
|
-
| `attributes.view.url` |  | str |
|
|
236
|
-
| `attributes.view.previous` |  | str |
|
|
237
|
-
| `attributes.view.previous_url_template` |  | str |
|
|
238
|
-
| `attributes.view.referrer` |  | str |
|
|
239
|
-
| `attributes.view.url_template` *[3]* |  | str |
|
|
240
|
-
| `attributes.view.loading_time` |  | number |
|
|
241
|
-
| `attributes.view.loading_time_source` |  | enum |
|
|
242
|
-
| `attributes.view.first_byte` |  | number |
|
|
248
|
+
| `attributes.view.id` |  | str | 页面 ID | |
|
|
249
|
+
| `attributes.view.name` *[1]* |  | str | 页面名称 | 如 `/apm/home`。 |
|
|
250
|
+
| `attributes.view.loading_type` *[2]* |  | str | 页面加载类型 | -- |
|
|
251
|
+
| `attributes.view.url` |  | str | 页面 URL | 如 `https://example.com/cur`。 |
|
|
252
|
+
| `attributes.view.previous` |  | str | 上一页面 URL | 如 `https://example.com/pre`。 |
|
|
253
|
+
| `attributes.view.previous_url_template` |  | str | 上一个页面 | 与 `view.url_template` 使用同一规则;初始 View 为空字符串。 |
|
|
254
|
+
| `attributes.view.referrer` |  | str | 初始来源 URL | 仅首次加载且值非空时上报,需进行 URL 脱敏。 |
|
|
255
|
+
| `attributes.view.url_template` *[3]* |  | str | 页面 | 如 `/apm/home`。 |
|
|
256
|
+
| `attributes.view.loading_time` |  | number | 页面加载耗时(ms) | 加载时间计算完成后上报。 |
|
|
257
|
+
| `attributes.view.loading_time_source` |  | enum | 页面加载计时方式 | `auto`、`manual`。 |
|
|
258
|
+
| `attributes.view.first_byte` |  | number | 页面首字节耗时(ms) | 仅初始导航存在。 |
|
|
243
259
|
| `attributes.view.dom_interactive` |  | number | DOM 可交互时间(ms) | 仅初始导航存在。 |
|
|
244
260
|
| `attributes.view.dom_content_loaded` |  | number | DOMContentLoaded 时间(ms) | 仅初始导航存在。 |
|
|
245
|
-
| `attributes.view.dom_complete` |  | number | DOM
|
|
246
|
-
| `attributes.view.load_event` |  | number | Load
|
|
247
|
-
| `attributes.view.phase` *[4]* |  | enum |
|
|
248
|
-
| `attributes.view.started_at` |  | number |
|
|
249
|
-
| `attributes.view.version` |  | int |
|
|
250
|
-
| `attributes.view.end_reason` |  | str |
|
|
261
|
+
| `attributes.view.dom_complete` |  | number | DOM 完成时间(ms) | 仅初始导航存在。 |
|
|
262
|
+
| `attributes.view.load_event` |  | number | Load 事件时间(ms) | 仅初始导航存在。 |
|
|
263
|
+
| `attributes.view.phase` *[4]* |  | enum | 页面阶段 | 枚举值:<br>- start<br>- update<br>- end |
|
|
264
|
+
| `attributes.view.started_at` |  | number | 页面开始时间(ms) | 初始 View 取 `performance.timeOrigin`(epoch ms);后续 View 取创建时刻。 |
|
|
265
|
+
| `attributes.view.version` |  | int | 页面快照版本 | 同一 `attributes.view.id` 从 `1` 开始递增,用于排序和幂等合并。 |
|
|
266
|
+
| `attributes.view.end_reason` |  | str | 页面结束原因 | -- |
|
|
251
267
|
|
|
252
|
-
**[1] `attributes.view.name
|
|
268
|
+
**[1] `attributes.view.name`**:优先使用 `startView({ name })` 或 `setViewName()` 设置的名称;未显式设置时,默认取 `attributes.view.url_template`。
|
|
253
269
|
|
|
254
270
|
**[2] `attributes.view.loading_type`**:
|
|
255
271
|
|
|
256
272
|
| 值 | 描述 |
|
|
257
273
|
| ----------------- | --------------- |
|
|
258
|
-
| `initial_load` |
|
|
259
|
-
| `route_change` |
|
|
274
|
+
| `initial_load` | 初始加载 |
|
|
275
|
+
| `route_change` | 路由切换 |
|
|
260
276
|
| `session_renewal` | 会话续期后重建 |
|
|
261
|
-
| `bf_cache` |
|
|
277
|
+
| `bf_cache` | 前进后退缓存恢复 |
|
|
262
278
|
|
|
263
279
|
**[3] `attributes.view.url_template`**:用于聚合的页面路径。默认把数字 ID、UUID 和长十六进制段替换为 `:id`,也可由 `tracking.view.getUrlTemplate` 自定义。
|
|
264
280
|
|
|
@@ -332,54 +348,110 @@ View B █████████████
|
|
|
332
348
|
| `attributes.resource.type` |  | enum | 资源类型 | -- |
|
|
333
349
|
| `attributes.resource.size` |  | int | 资源大小 | -- |
|
|
334
350
|
| `attributes.resource.transfer_size` |  | int | 传输大小 | -- |
|
|
335
|
-
| `attributes.resource.decoded_body_size` |  | int |
|
|
336
|
-
| `attributes.resource.encoded_body_size` |  | int |
|
|
337
|
-
| `attributes.resource.protocol` |  | str |
|
|
338
|
-
| `attributes.resource.cache.hit` |  | boolean |
|
|
339
|
-
| `attributes.resource.delivery_type` |  | str |
|
|
340
|
-
| `attributes.resource.render_blocking_status` |  | enum | 渲染阻塞状态 |
|
|
341
|
-
| `attributes.resource.redirect.start` |  | int | 解压后大小 | -- |
|
|
352
|
+
| `attributes.resource.encoded_body_size` |  | int | 压缩后大小 | -- |
|
|
353
|
+
| `attributes.resource.protocol` |  | str | 资源协议 | 浏览器提供下一跳协议时存在,如 `h2`、`h3`、`http/1.1`。 |
|
|
354
|
+
| `attributes.resource.cache.hit` *[3]* |  | boolean | 缓存命中 | 命中时为 `true`,未命中或无法判断时不写入。 |
|
|
355
|
+
| `attributes.resource.delivery_type` *[4]* |  | str | 资源获取方式 | 浏览器返回非空值时存在。 |
|
|
356
|
+
| `attributes.resource.render_blocking_status` *[5]* |  | enum | 渲染阻塞状态 | 浏览器支持该字段时存在。 |
|
|
357
|
+
| `attributes.resource.redirect.start` |  | number | 重定向开始时间 | 可由 `redirectStart - startTime` 得到。 |
|
|
358
|
+
| `attributes.resource.redirect.duration` |  | number | 重定向耗时 | 可由 `redirectEnd - redirectStart` 得到。 |
|
|
359
|
+
| `attributes.resource.worker.start` |  | number | Service Worker 开始时间 | 可由 `workerStart - startTime` 得到。 |
|
|
360
|
+
| `attributes.resource.worker.duration` |  | number | Service Worker 耗时 | 可由 `fetchStart - workerStart` 得到。 |
|
|
361
|
+
| `attributes.resource.dns.start` |  | number | DNS 解析开始时间 | 可由 `domainLookupStart - startTime` 得到。 |
|
|
362
|
+
| `attributes.resource.dns.duration` |  | number | DNS 解析耗时 | 可由 `domainLookupEnd - domainLookupStart` 得到。 |
|
|
363
|
+
| `attributes.resource.connect.start` |  | number | 连接开始时间 | 可由 `connectStart - startTime` 得到。 |
|
|
364
|
+
| `attributes.resource.connect.duration` |  | number | 连接耗时(含 TLS) | 可由 `connectEnd - connectStart` 得到。 |
|
|
365
|
+
| `attributes.resource.ssl.start` |  | number | TLS 握手开始时间 | 可由 `secureConnectionStart - startTime` 得到。 |
|
|
366
|
+
| `attributes.resource.ssl.duration` |  | number | TLS 握手耗时 | 可由 `connectEnd - secureConnectionStart` 得到。 |
|
|
367
|
+
| `attributes.resource.first_byte.start` |  | number | 首字节等待开始时间 | 可由 `requestStart - startTime` 得到。 |
|
|
368
|
+
| `attributes.resource.first_byte.duration` |  | number | 首字节等待耗时 | 可由 `responseStart - requestStart` 得到。 |
|
|
369
|
+
| `attributes.resource.download.start` |  | number | 内容下载开始时间 | 可由 `responseStart - startTime` 得到。 |
|
|
370
|
+
| `attributes.resource.download.duration` |  | number | 内容下载耗时 | 可由 `responseEnd - responseStart` 得到。 |
|
|
371
|
+
| `attributes.resource.timing.start_time` |  | number | 资源开始时间 | 与 `responseEnd` 计算总耗时;也是阶段偏移基准。 |
|
|
372
|
+
| `attributes.resource.timing.redirect_start` |  | number | 重定向开始时间 | 与 `redirectEnd` 计算可见重定向链耗时。 |
|
|
373
|
+
| `attributes.resource.timing.redirect_end` |  | number | 重定向结束时间 | -- |
|
|
374
|
+
| `attributes.resource.timing.fetch_start` |  | number | 最后一跳获取开始时间 | 划分重定向后的前置等待。 |
|
|
375
|
+
| `attributes.resource.timing.worker_start` |  | number | Service Worker 介入时间 | 标记 Service Worker 参与,不代表实际执行耗时。 |
|
|
376
|
+
| `attributes.resource.timing.worker_router_evaluation_start` |  | number | Service Worker 路由评估时间 | 标记静态路由评估。 |
|
|
377
|
+
| `attributes.resource.timing.worker_cache_lookup_start` |  | number | Service Worker 缓存查询时间 | 标记缓存查询,不代表命中。 |
|
|
378
|
+
| `attributes.resource.timing.domain_lookup_start` |  | number | DNS 查询开始时间 | 与 `domainLookupEnd` 计算 DNS 耗时。 |
|
|
379
|
+
| `attributes.resource.timing.domain_lookup_end` |  | number | DNS 查询结束时间 | -- |
|
|
380
|
+
| `attributes.resource.timing.connect_start` |  | number | 连接开始时间 | 与 `connectEnd` 计算连接耗时(含 TLS)。 |
|
|
381
|
+
| `attributes.resource.timing.secure_connection_start` |  | number | TLS 开始时间 | 与 `connectEnd` 计算 TLS 耗时。 |
|
|
382
|
+
| `attributes.resource.timing.connect_end` |  | number | 连接完成时间 | -- |
|
|
383
|
+
| `attributes.resource.timing.request_start` |  | number | 请求开始时间 | 与 `responseStart` 计算等待首个响应的耗时。 |
|
|
384
|
+
| `attributes.resource.timing.response_start` |  | number | 首个响应时间 | 早于 `finalResponseHeadersStart` 时可识别 1xx;相等或最终响应头缺失,不能排除 1xx。 |
|
|
385
|
+
| `attributes.resource.timing.final_response_headers_start` |  | number | 最终响应头时间 | 与 `responseEnd` 计算最终响应交付耗时。 |
|
|
386
|
+
| `attributes.resource.timing.response_end` |  | number | 响应结束时间 | -- |
|
|
387
|
+
| `attributes.resource.timing.worker_matched_router_source` |  | str | Service Worker 命中来源 | 用于区分路由命中路径,可能不是最终来源。 |
|
|
388
|
+
| `attributes.resource.timing.worker_final_router_source` |  | str | Service Worker 最终来源 | 用于确定最终交付路径。 |
|
|
355
389
|
|
|
356
390
|
**[1] `attributes.resource.type`**:
|
|
357
391
|
|
|
358
392
|
| 值 | 描述 |
|
|
359
393
|
| ------------------ | -------------------------------------------- |
|
|
360
|
-
| `fetch` | Fetch
|
|
361
|
-
| `xhr` |
|
|
362
|
-
| `script` |
|
|
363
|
-
| `link` |
|
|
364
|
-
| `img` / `image` | HTML 或 SVG 图片元素加载的资源。 |
|
|
365
|
-
| `css` | CSS `url()`、`@import` 等规则加载的资源,不表示 CSS 文件本身。 |
|
|
394
|
+
| `fetch` | Fetch 请求。 |
|
|
395
|
+
| `xhr` | XHR 请求。 |
|
|
396
|
+
| `script` | 脚本加载:`<script>`、模块或 Worker 加载的脚本资源。 |
|
|
397
|
+
| `link` | Link 标签加载:`<link>` 加载的资源,如样式表、预加载和预取资源。 |
|
|
398
|
+
| `img` / `image` | 图片:HTML 或 SVG 图片元素加载的资源。 |
|
|
399
|
+
| `css` | CSS 规则加载:CSS `url()`、`@import` 等规则加载的资源,不表示 CSS 文件本身。 |
|
|
366
400
|
| `iframe` / `frame` | 内嵌页面加载的文档资源。 |
|
|
367
|
-
| `other` |
|
|
401
|
+
| `other` | 其他:浏览器未识别发起方式、`initiatorType` 为空或未单列的其他类型。 |
|
|
368
402
|
| ... | .. |
|
|
369
403
|
|
|
370
404
|
**[2] 单位**:`xx_size` 为 bytes,`duration` & `start` 为毫秒。
|
|
371
405
|
|
|
372
|
-
**[3]
|
|
406
|
+
**[3] `attributes.resource.cache.hit`**
|
|
407
|
+
|
|
408
|
+
满足任一条件时,SDK 写入 `true`:
|
|
409
|
+
|
|
410
|
+
| 条件 | 结果 |
|
|
411
|
+
| --- | --- |
|
|
412
|
+
| `deliveryType=cache` | `true` |
|
|
413
|
+
| `transferSize=0 && decodedBodySize>0` | `true` |
|
|
414
|
+
| 其他 | 不写入,不写 `false` |
|
|
415
|
+
|
|
416
|
+
ETag(实体标签)是服务器提供的资源版本标识。浏览器按以下流程校验缓存:
|
|
417
|
+
|
|
418
|
+
```text
|
|
419
|
+
缓存 ETag → If-None-Match → 304 → 复用本地正文
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
`deliveryType=cache` 与 `transferSize>0` 不冲突。[Resource Timing](https://www.w3.org/TR/resource-timing/) 把 `validated` 缓存的 `transferSize` 记为 `300`,不是正文大小。
|
|
423
|
+
|
|
424
|
+
**[4] `attributes.resource.delivery_type`**:
|
|
425
|
+
|
|
426
|
+
| 常见值 | 描述 |
|
|
427
|
+
| ----------------------- | ---------------------------------------------------------- |
|
|
428
|
+
| `cache` | 由浏览器 HTTP 缓存交付,包括本地缓存和网络校验缓存。 |
|
|
429
|
+
| `navigational-prefetch` | 由导航预取缓冲区交付。 |
|
|
430
|
+
| `cache-storage` | 由 Cache Storage 交付,包括 Service Worker Fetch Handler 和静态路由命中。 |
|
|
431
|
+
|
|
432
|
+
规范来源:[Resource Timing](https://www.w3.org/TR/resource-timing/)、[Prefetch](https://wicg.github.io/nav-speculation/prefetch.html)、[Chromium Cache Storage Timing](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/experiments/service-worker-static-routing-api-timing-info.md)。
|
|
433
|
+
|
|
434
|
+
SDK 原样上报浏览器返回的非空值,空值不写入。
|
|
435
|
+
|
|
436
|
+
**[5] `attributes.resource.render_blocking_status`**:
|
|
437
|
+
|
|
438
|
+
| 值 | 描述 |
|
|
439
|
+
| -------------- | ----------- |
|
|
440
|
+
| `blocking` | 可能阻塞渲染。 |
|
|
441
|
+
| `non-blocking` | 不阻塞渲染。 |
|
|
442
|
+
|
|
443
|
+
取值定义见 [Resource Timing](https://www.w3.org/TR/resource-timing/)。浏览器不支持该字段时,SDK 不写入。
|
|
373
444
|
|
|
374
445
|
### i. action
|
|
375
446
|
|
|
376
447
|
| 字段 | 状态 | 类型 | 描述 |
|
|
377
448
|
| ------------------------------------------ | ---------------------------------------------------------- | ----- | ------ |
|
|
378
|
-
| `attributes.action.id` |  | str |
|
|
379
|
-
| `attributes.action.
|
|
380
|
-
| `attributes.action.
|
|
381
|
-
| `attributes.action.target.
|
|
382
|
-
| `attributes.action.
|
|
449
|
+
| `attributes.action.id` |  | str | 操作 ID |
|
|
450
|
+
| `attributes.action.name` |  | str | 可读的低基数动作名称,也是 `span_name` |
|
|
451
|
+
| `attributes.action.type` *[2]* |  | str | 操作类型 |
|
|
452
|
+
| `attributes.action.target.name` |  | str | 操作元素 |
|
|
453
|
+
| `attributes.action.target.tag` |  | str | 操作元素标签 |
|
|
454
|
+
| `attributes.action.frustration.type` *[3]* |  | str[] | 异常点击类型 |
|
|
383
455
|
|
|
384
456
|
|
|
385
457
|
**[1] `attributes.action.loading_time`**:当前浏览器 SDK 不写该 Attribute。有页面活动时,用 Span 起止时间(后端 `elapsed_time`)表达持续时长。
|
|
@@ -389,7 +461,7 @@ View B █████████████
|
|
|
389
461
|
| 常见值 | 描述 |
|
|
390
462
|
| -------------------- | ---------------------------------- |
|
|
391
463
|
| `click` | 鼠标或指针设备触发的点击,蓝鲸 Web 自动 Action 当前使用该值。 |
|
|
392
|
-
| `custom` | 通过 `reportAction({ name })` 主动上报;Span
|
|
464
|
+
| `custom` | 通过 `reportAction({ name })` 主动上报;Span 名使用 `action.name`。 |
|
|
393
465
|
| `tap` | 触屏设备上的单次轻触。 |
|
|
394
466
|
| `scroll` | 页面或滚动容器的滚动操作。 |
|
|
395
467
|
| `swipe` | 触屏设备上的滑动手势。 |
|
|
@@ -400,11 +472,11 @@ View B █████████████
|
|
|
400
472
|
|
|
401
473
|
**[3] `attributes.action.frustration.type`**:
|
|
402
474
|
|
|
403
|
-
| 值 | 描述 |
|
|
404
|
-
| ------------- | ------------------------------------------------------------------------------------ |
|
|
405
|
-
| `rage_click` | [a] `1 s` 内对同一 DOM 元素连续点击至少 `3` 次,且相邻点击距离不超过 `100 px`。<br />[b] 滚动或文本选择会中断或撤销判定。 |
|
|
406
|
-
| `dead_click` | [a] 点击后未检测到请求、资源加载、长任务、DOM 变化、打开窗口或错误,也没有输入、滚动或文本选择。<br />[b] 链接、文本输入框等难以可靠判断的目标会排除。 |
|
|
407
|
-
| `error_click` | Action 生命周期内检测到前端错误。 |
|
|
475
|
+
| 值 | 描述 | 备注 |
|
|
476
|
+
| ------------- | ---- | ------------------------------------------------------------------------------------ |
|
|
477
|
+
| `rage_click` | 愤怒点击 | [a] `1 s` 内对同一 DOM 元素连续点击至少 `3` 次,且相邻点击距离不超过 `100 px`。<br />[b] 滚动或文本选择会中断或撤销判定。 |
|
|
478
|
+
| `dead_click` | 无响应点击 | [a] 点击后未检测到请求、资源加载、长任务、DOM 变化、打开窗口或错误,也没有输入、滚动或文本选择。<br />[b] 链接、文本输入框等难以可靠判断的目标会排除。 |
|
|
479
|
+
| `error_click` | 报错点击 | Action 生命周期内检测到前端错误。 |
|
|
408
480
|
|
|
409
481
|
该字段为数组,同一个 Action 可以同时命中多个值;未命中时不写入。消费端应按集合处理,不依赖数组顺序。这些信号是 SDK 的启发式判断,不等同于业务操作失败。
|
|
410
482
|
|
|
@@ -413,43 +485,43 @@ View B █████████████
|
|
|
413
485
|
| 字段 | 状态 | 类型 | 描述 | |
|
|
414
486
|
| -------------------------------------- | ---------------------------------------------------------- | --- | ------ | ---------------------------- |
|
|
415
487
|
| `attributes.url.full` |  | str | 完整 URL | 如 `https://example.com/apm`。 |
|
|
416
|
-
| `attributes.url.scheme` |  | str | 协议 | 如 `ws`、`wss`。 |
|
|
417
|
-
| `attributes.url.template` |  | str |
|
|
418
|
-
| `attributes.http.request.method` |  | str | 请求方法 |
|
|
419
|
-
| `attributes.http.response.status_code` |  | int |
|
|
420
|
-
| `attributes.server.address` |  | str |
|
|
421
|
-
| `attributes.server.port` |  | int |
|
|
488
|
+
| `attributes.url.scheme` |  | str | URL 协议 | 如 `ws`、`wss`。 |
|
|
489
|
+
| `attributes.url.template` |  | str | 资源路径 | 如 `/api/users/`。 |
|
|
490
|
+
| `attributes.http.request.method` |  | str | 请求方法 | Fetch/XHR 使用实际方法;其他 Resource 固定为 `GET`。 |
|
|
491
|
+
| `attributes.http.response.status_code` |  | int | HTTP 状态码 | 如 `200`、`404`。 |
|
|
492
|
+
| `attributes.server.address` |  | str | 服务器地址 | 如 `example.com`。 |
|
|
493
|
+
| `attributes.server.port` |  | int | 服务器端口 | -- |
|
|
422
494
|
|
|
423
495
|
### k. vital
|
|
424
496
|
|
|
425
497
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
426
498
|
| --------------------------------------------- | ---------------------------------------------------------- | ------ | -------------------- | ------------------------------------ |
|
|
427
|
-
| `attributes.vital.id` |  | str |
|
|
428
|
-
| `attributes.vital.metric` |  | enum |
|
|
429
|
-
| `attributes.vital.value` |  | number |
|
|
499
|
+
| `attributes.vital.id` |  | str | 指标 ID | |
|
|
500
|
+
| `attributes.vital.metric` |  | enum | 指标 | |
|
|
501
|
+
| `attributes.vital.value` |  | number | 指标值 | |
|
|
430
502
|
| `attributes.vital.inp.input_delay` |  | number | 输入延迟(ms) | 用户发起交互(如点击)到事件处理器开始执行的等待时间,反映主线程繁忙程度 |
|
|
431
|
-
| `attributes.vital.inp.interaction_target` |  | str |
|
|
503
|
+
| `attributes.vital.inp.interaction_target` |  | str | 交互目标元素 | 如 `div`。 |
|
|
432
504
|
| `attributes.vital.inp.interaction_type` |  | str | 交互类型 | -- |
|
|
433
|
-
| `attributes.vital.inp.processing_duration` |  | number |
|
|
505
|
+
| `attributes.vital.inp.processing_duration` |  | number | 交互处理耗时(ms) | -- |
|
|
434
506
|
| `attributes.vital.inp.presentation_delay` |  | number | 呈现延迟(ms) | -- |
|
|
435
|
-
| `attributes.vital.lcp.target` |  | str |
|
|
436
|
-
| `attributes.vital.lcp.url` |  | str |
|
|
437
|
-
| `attributes.vital.lcp.resource_load_duration` |  | number | 资源加载耗时(ms) | -- |
|
|
438
|
-
| `attributes.vital.lcp.element_render_delay` |  | number | 元素渲染延迟(ms) | -- |
|
|
439
|
-
| `attributes.vital.ttfb.waiting_duration` |  | number |
|
|
440
|
-
| `attributes.vital.ttfb.dns_duration` |  | number | DNS
|
|
441
|
-
| `attributes.vital.ttfb.connection_duration` |  | number |
|
|
442
|
-
| `attributes.vital.ttfb.request_duration` |  | number |
|
|
507
|
+
| `attributes.vital.lcp.target` |  | str | LCP 元素选择器 | 如 `div`。 |
|
|
508
|
+
| `attributes.vital.lcp.url` |  | str | LCP 资源 URL(已脱敏) | -- |
|
|
509
|
+
| `attributes.vital.lcp.resource_load_duration` |  | number | LCP 资源加载耗时(ms) | -- |
|
|
510
|
+
| `attributes.vital.lcp.element_render_delay` |  | number | LCP 元素渲染延迟(ms) | -- |
|
|
511
|
+
| `attributes.vital.ttfb.waiting_duration` |  | number | 请求准备耗时(ms) | -- |
|
|
512
|
+
| `attributes.vital.ttfb.dns_duration` |  | number | DNS 阶段耗时(ms) | -- |
|
|
513
|
+
| `attributes.vital.ttfb.connection_duration` |  | number | 连接耗时(含 TLS)(ms) | -- |
|
|
514
|
+
| `attributes.vital.ttfb.request_duration` |  | number | 请求阶段耗时(ms) | -- |
|
|
443
515
|
|
|
444
516
|
**[1] `attributes.vital.metric`**:
|
|
445
517
|
|
|
446
518
|
| 值 | 描述 | 备注 |
|
|
447
519
|
| ---- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
448
|
-
| cls | [
|
|
449
|
-
| inp | [
|
|
450
|
-
| lcp | [
|
|
451
|
-
| fcp | [
|
|
452
|
-
| ttfb | [
|
|
520
|
+
| cls | [CLS(累积布局偏移)](https://web.dev/articles/cls) | 在整个页面生命周期中,每次出现的意外布局变化所导致的最大布局变化得分的累积值,为了提供良好的用户体验,网站的 CLS 得分应控制在 0.1 或更低。 |
|
|
521
|
+
| inp | [INP(交互到下一次绘制)](https://web.dev/articles/inp) | 记录用户与页面进行的所有交互的延迟情况,并给出一个综合评分(通常是 P98,忽略极端值),较低的 INP 值意味着页面能够快速响应所有或绝大多数用户交互,INP 值在用户离开页面时会被计算出来。 |
|
|
522
|
+
| lcp | [LCP(最大内容绘制)](https://web.dev/articles/lcp) | Core Web Vital 中的一个重要且稳定的指标,测量从页面开始加载,到视窗中可见的最大图像、文本块或视频的渲染时间,用于衡量页面加载的速度(用户感受:页面主要内容出来了)。 |
|
|
523
|
+
| fcp | [FCP(首次内容绘制)](https://web.dev/articles/fcp) | 从用户首次访问页面,到页面第一次显示出任何内容的耗时(用户感受:不是白屏了)。 |
|
|
524
|
+
| ttfb | [TTFB(首字节耗时)](https://web.dev/articles/ttfb) | 从用户开始导航到页面到响应首字节开始传输之间所经历的时间。 |
|
|
453
525
|
|
|
454
526
|
**[2] `attributes.vital.value`**:CLS 单位为 `1`,FCP、INP、LCP、TTFB 单位为 `ms`。
|
|
455
527
|
|
|
@@ -461,8 +533,8 @@ View B █████████████
|
|
|
461
533
|
| ------------- | ------------- |
|
|
462
534
|
| `keyup` | 松开按键 |
|
|
463
535
|
| `keydown` | 按下按键 |
|
|
464
|
-
| `pointerdown` |
|
|
465
|
-
| `pointerup` |
|
|
536
|
+
| `pointerdown` | 指针按下 |
|
|
537
|
+
| `pointerup` | 指针松开 |
|
|
466
538
|
|
|
467
539
|
**[5] `attributes.vital.inp.processing_duration`**:事件处理回调(如 click handler)本身的执行时间,JS 逻辑过重时这个值会变大。
|
|
468
540
|
|
|
@@ -489,8 +561,8 @@ View B █████████████
|
|
|
489
561
|
| 字段 | 状态 | 类型 | 描述 | 备注 |
|
|
490
562
|
| ---------------------------------------------- | --------------------------------------------------------------- | ------- | ---------------- | ------------------ |
|
|
491
563
|
| `attributes.blank_screen.reason` *[1]* |  | str | 白屏判定原因 | |
|
|
492
|
-
| `attributes.blank_screen.empty_ratio` |  | number |
|
|
493
|
-
| `attributes.blank_screen.empty_sample_count` |  | int |
|
|
564
|
+
| `attributes.blank_screen.empty_ratio` |  | number | 空白点占比 | 回退根节点检测时仍为实际比例,不是固定 `1`。 |
|
|
565
|
+
| `attributes.blank_screen.empty_sample_count` |  | int | 空白点数量 | |
|
|
494
566
|
|
|
495
567
|
**[1] `attributes.blank_screen.reason`**:
|
|
496
568
|
|
|
@@ -504,10 +576,10 @@ View B █████████████
|
|
|
504
576
|
| 字段 | 状态 | 类型 | 描述 |
|
|
505
577
|
| ----------------------------------------------- | --------------------------------------------------------------- | ------ | -------------------- |
|
|
506
578
|
| `attributes.long_task.id` |  | str | 长任务或长动画帧 ID |
|
|
507
|
-
| `attributes.long_task.name` |  | str |
|
|
508
|
-
| `attributes.long_task.entry_type` *[1]* |  | str |
|
|
579
|
+
| `attributes.long_task.name` |  | str | 长任务名称 |
|
|
580
|
+
| `attributes.long_task.entry_type` *[1]* |  | str | 长任务类型 |
|
|
509
581
|
| `attributes.long_task.blocking_duration` |  | number | 主线程阻塞耗时(ms) |
|
|
510
|
-
| `attributes.long_task.first_ui_event_timestamp` |  | number |
|
|
582
|
+
| `attributes.long_task.first_ui_event_timestamp` |  | number | 首个交互事件时间(ms) |
|
|
511
583
|
| `attributes.long_task.render_start` |  | number | 渲染阶段开始时间(ms) |
|
|
512
584
|
| `attributes.long_task.style_and_layout_start` |  | number | 样式与布局阶段开始时间(ms) |
|
|
513
585
|
|
|
@@ -520,149 +592,171 @@ View B █████████████
|
|
|
520
592
|
|
|
521
593
|
### n. custom
|
|
522
594
|
|
|
523
|
-
`reportCustomEvent()` 产生 `custom.<name>` Span。`reportAction({ name })`
|
|
595
|
+
`reportCustomEvent()` 产生 `custom.<name>` Span。`reportAction({ name })` 产生以 `action.name` 命名的 Span,且 `action.type=custom`。
|
|
524
596
|
|
|
525
597
|
## 0x04 资源加载时序
|
|
526
598
|
|
|
527
|
-
本文对照 W3C Resource Timing、Chrome Timing 和 web.dev,并给出 Resource Span 请求时序的产品划分。适用范围是单次 `resource` Span 的阶段图,不含 View 导航瀑布。
|
|
528
|
-
|
|
529
|
-
阶段名称靠近 Chrome Timing。每段时长用已上报的 `attributes.resource.*.duration` 计算,起点用对应的 `start`,单位为毫秒,相对该资源 `startTime`。
|
|
530
|
-
|
|
531
|
-
产品按 `attributes.view.id` 关联 View 生命周期快照后,可用 `attributes.view.previous_url_template` 展示资源所属页面的前序路由。该字段与 `attributes.view.url_template` 使用同一模板规则,初始 View 为空字符串;它不参与 Resource Timing 阶段计算,也不直接写入 `resource` Span。
|
|
532
|
-
|
|
533
599
|
### a. W3C Resource Timing
|
|
534
600
|
|
|
535
|
-
|
|
601
|
+
字段定义见 [PerformanceResourceTiming](https://www.w3.org/TR/resource-timing/#the-performanceresourcetiming-interface)。下表按生命周期排序。
|
|
536
602
|
|
|
537
|
-
|
|
|
538
|
-
| --- | --- | --- |
|
|
539
|
-
| 1 | `startTime` | 这次取资源开始 |
|
|
540
|
-
| 2 | `redirectStart` | 第一次重定向开始 |
|
|
541
|
-
| 3 | `redirectEnd` | 最后一次重定向的响应收完 |
|
|
542
|
-
| 4 | `workerStart` | Service Worker 开始处理这次请求;未拦截时为 `0` |
|
|
543
|
-
| 5 | `fetchStart` | 重定向结束后,开始取最终资源 |
|
|
544
|
-
| 6 | `domainLookupStart` | DNS 查询开始 |
|
|
545
|
-
| 7 | `domainLookupEnd` | DNS 查询结束 |
|
|
546
|
-
| 8 | `connectStart` | 开始建立到服务器的连接 |
|
|
547
|
-
| 9 | `secureConnectionStart` | TLS 握手开始;非 HTTPS 时为 `0` |
|
|
548
|
-
| 10 | `connectEnd` | 连接建立完成,TLS 包含在内 |
|
|
549
|
-
| 11 | `requestStart` | 开始向服务器发请求 |
|
|
550
|
-
| 12 | `firstInterimResponseStart` | 中间响应,例如 `103` |
|
|
551
|
-
| 13 | `responseStart` | 收到响应首字节 |
|
|
552
|
-
| 14 | `finalResponseHeadersStart` | 最终响应头开始,通常是 `200` |
|
|
553
|
-
| 15 | `responseEnd` | 最后一字节到达,或连接先关闭 |
|
|
554
|
-
|
|
555
|
-
用上面的时间点可以算出这些耗时:
|
|
556
|
-
|
|
557
|
-
| 顺序 | 耗时 | 计算 |
|
|
603
|
+
| 字段 | 含义 | attribute |
|
|
558
604
|
| --- | --- | --- |
|
|
559
|
-
|
|
|
560
|
-
|
|
|
561
|
-
|
|
|
562
|
-
|
|
|
563
|
-
|
|
|
564
|
-
|
|
|
565
|
-
|
|
|
605
|
+
| `startTime` | 这次取资源开始 | `attributes.resource.timing.start_time` |
|
|
606
|
+
| `redirectStart` | 第一次重定向开始 | `attributes.resource.timing.redirect_start` |
|
|
607
|
+
| `redirectEnd` | 最后一次重定向的响应收完 | `attributes.resource.timing.redirect_end` |
|
|
608
|
+
| `workerStart` | Service Worker 开始处理这次请求;未拦截时为 `0` | `attributes.resource.timing.worker_start` |
|
|
609
|
+
| `workerRouterEvaluationStart` | Service Worker 静态路由开始评估 | `attributes.resource.timing.worker_router_evaluation_start` |
|
|
610
|
+
| `workerCacheLookupStart` | Service Worker 静态路由开始查 Cache Storage,不代表命中 | `attributes.resource.timing.worker_cache_lookup_start` |
|
|
611
|
+
| `fetchStart` | 重定向结束后,开始取最终资源 | `attributes.resource.timing.fetch_start` |
|
|
612
|
+
| `domainLookupStart` | DNS 查询开始 | `attributes.resource.timing.domain_lookup_start` |
|
|
613
|
+
| `domainLookupEnd` | DNS 查询结束 | `attributes.resource.timing.domain_lookup_end` |
|
|
614
|
+
| `connectStart` | 开始建立到服务器的连接 | `attributes.resource.timing.connect_start` |
|
|
615
|
+
| `secureConnectionStart` | 可见 TLS 握手开始时间;复用连接时也可能被钳到 `fetchStart`,不能单凭非零值判断本次发生握手 | `attributes.resource.timing.secure_connection_start` |
|
|
616
|
+
| `connectEnd` | 连接建立完成,TLS 包含在内 | `attributes.resource.timing.connect_end` |
|
|
617
|
+
| `requestStart` | 开始向服务器发请求 | `attributes.resource.timing.request_start` |
|
|
618
|
+
| `firstInterimResponseStart` | 中间响应,例如 `103` | — |
|
|
619
|
+
| `responseStart` | 首个响应开始;存在 1xx 时指向首个临时响应,否则指向最终响应头 | `attributes.resource.timing.response_start` |
|
|
620
|
+
| `finalResponseHeadersStart` | 最终响应头开始;不保证浏览器均支持 | `attributes.resource.timing.final_response_headers_start` |
|
|
621
|
+
| `responseEnd` | 最后一字节到达,或连接先关闭 | `attributes.resource.timing.response_end` |
|
|
622
|
+
| `duration` | 总耗时,`responseEnd − startTime` | — |
|
|
623
|
+
| `name` | 资源 URL | `attributes.url.full` |
|
|
624
|
+
| `entryType` | 性能条目类型,固定为 `resource` | — |
|
|
625
|
+
| `initiatorType` | 发起方式,如 `script`、`link`、`img`、`fetch` | `attributes.resource.type` |
|
|
626
|
+
| `navigationId` | 所属页面导航的 ID | — |
|
|
627
|
+
| `nextHopProtocol` | 网络协议,如 `h2`、`h3` | `attributes.resource.protocol` |
|
|
628
|
+
| `deliveryType` | 资源获取方式,如 `cache`、`navigational-prefetch` | `attributes.resource.delivery_type` |
|
|
629
|
+
| `responseStatus` | HTTP 状态码 | `attributes.http.response.status_code` |
|
|
630
|
+
| `contentType` | 响应内容类型 | — |
|
|
631
|
+
| `contentEncoding` | 响应内容编码,如 `gzip`、`br` | — |
|
|
632
|
+
| `transferSize` | 规范化传输大小;本地缓存为 `0`,不是精确网络流量 | `attributes.resource.transfer_size` |
|
|
633
|
+
| `encodedBodySize` | 压缩后正文大小 | `attributes.resource.encoded_body_size` |
|
|
634
|
+
| `decodedBodySize` | 解码/解压后正文大小 | `attributes.resource.decoded_body_size` |
|
|
635
|
+
| `renderBlockingStatus` | 渲染阻塞状态 | `attributes.resource.render_blocking_status` |
|
|
636
|
+
| `serverTiming` | 服务端返回的 Server-Timing 指标 | — |
|
|
637
|
+
| `workerMatchedSourceType` | Service Worker 静态路由命中的来源 | `attributes.resource.timing.worker_matched_router_source` |
|
|
638
|
+
| `workerFinalSourceType` | Service Worker 最终使用的来源 | `attributes.resource.timing.worker_final_router_source` |
|
|
639
|
+
|
|
640
|
+
### b. 阶段划分
|
|
641
|
+
|
|
642
|
+
下表使用 `attributes.resource.timing` 上报字段计算阶段。绘图时,阶段时间点无效、顺序异常或计算耗时小于等于 `0`,均不画阶段条。
|
|
643
|
+
|
|
644
|
+
| 阶段 | 计算 | 术语介绍 | 用户感受 | 官方定义 |
|
|
645
|
+
| --- | --- | --- | --- | --- |
|
|
646
|
+
| 重定向 | `attributes.resource.timing.redirect_end − attributes.resource.timing.redirect_start` | 服务器返回 3xx 和新地址后,浏览器立即请求新地址,可能经过多次跳转,每次都多一次往返。 | 浏览器正在按服务器给出的新地址重新请求。 | W3C:[redirectStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-redirectstart)、[redirectEnd](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-redirectend) |
|
|
647
|
+
| 发起前等待 | C|D|E 类(无重定向):`attributes.resource.timing.fetch_start − attributes.resource.timing.start_time`<br />D|E 类(有重定向):`attributes.resource.timing.fetch_start − attributes.resource.timing.redirect_end` | 浏览器开始获取资源前的准备时间。 | 浏览器正在准备获取资源。 | W3C:[fetchStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-fetchstart) |
|
|
648
|
+
| [资源调度] 正在排队 | B 类:`attributes.resource.timing.worker_start − attributes.resource.timing.start_time` | 请求在连接开始前被排入队列,原因可能是有更高优先级的请求,或者同一来源的连接数已满。 | 浏览器正在排队,等待处理这次请求。 | W3C:[workerStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-workerstart);DevTools:`[资源调度] 正在排队` |
|
|
649
|
+
| [ServiceWorker] 启动 | `attributes.resource.timing.fetch_start − attributes.resource.timing.worker_start` | 浏览器启动 Service Worker,以便由它处理这次请求。 | 浏览器正在启动 Service Worker。 | W3C:[workerStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-workerstart);DevTools:[ServiceWorker] 启动 |
|
|
650
|
+
| [ServiceWorker] 向 ServiceWorker 发送的请求 | `attributes.resource.timing.request_start − attributes.resource.timing.fetch_start` | 浏览器把请求发送给 Service Worker 处理。 | 浏览器正在把请求发送给 Service Worker。 | W3C:[requestStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-requeststart);DevTools:`[ServiceWorker] 向 ServiceWorker 发送的请求` |
|
|
651
|
+
| [ServiceWorker] respondWith | 有首字节时间:`attributes.resource.timing.response_start − attributes.resource.timing.request_start`<br />无首字节时间:`attributes.resource.timing.response_end − attributes.resource.timing.request_start`<br />`attributes.resource.timing.request_start = 0` 时,起点改用 `attributes.resource.timing.fetch_start` | Service Worker 拦截请求后自行提供响应,例如读缓存或访问网络。 | Service Worker 正在处理请求,浏览器在等它交回响应。 | W3C:[Service Worker `respondWith`](https://w3c.github.io/ServiceWorker/#fetch-event-respondwith);DevTools:`[ServiceWorker] respondWith` |
|
|
652
|
+
| DNS | `attributes.resource.timing.domain_lookup_end − attributes.resource.timing.domain_lookup_start` | 浏览器通过 DNS 把资源域名解析为 IP 地址。 | 浏览器正在解析请求的 IP 地址。 | W3C:[domainLookupStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-domainlookupstart)、[domainLookupEnd](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-domainlookupend) |
|
|
653
|
+
| 连接建立 | 有 TLS:`attributes.resource.timing.secure_connection_start − attributes.resource.timing.connect_start`<br />无 TLS:`attributes.resource.timing.connect_end − attributes.resource.timing.connect_start` | 浏览器通过 TCP 握手与服务器建立连接。 | 浏览器正在和服务器建立连接。 | W3C:[connectStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-connectstart)、[connectEnd](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-connectend) |
|
|
654
|
+
| TLS | `attributes.resource.timing.connect_end − attributes.resource.timing.secure_connection_start` | 浏览器与服务器协商加密方式并验证服务器身份,建立安全连接。 | 浏览器正在和服务器确认身份、协商加密。 | W3C:[secureConnectionStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-secureconnectionstart);Fetch:[复用连接的时间点钳制](https://fetch.spec.whatwg.org/#clamp-and-coarsen-connection-timing-info) |
|
|
655
|
+
| 等待首字节 | D|E 类:`attributes.resource.timing.response_start − attributes.resource.timing.connect_end`<br />B 类:`attributes.resource.timing.response_start − attributes.resource.timing.request_start`(`attributes.resource.timing.request_start = 0` 时改用 `attributes.resource.timing.fetch_start`)<br />C 类:`attributes.resource.timing.response_start − attributes.resource.timing.fetch_start` | 浏览器发出请求后,等待服务器准备并返回响应第一个字节的时间。 | 浏览器正在发送请求并等待服务器回应。 | W3C:[requestStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-requeststart)、[responseStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-responsestart) |
|
|
656
|
+
| 内容下载 | 有首字节时间:`attributes.resource.timing.response_end − attributes.resource.timing.response_start`<br />B|C 类无首字节时间:`attributes.resource.timing.response_end − attributes.resource.timing.fetch_start` | 浏览器接收响应内容,从第一个字节到最后一个字节。 | 浏览器正在接收响应内容。 | W3C:[responseStart](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-responsestart)、[responseEnd](https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-responseend) |
|
|
657
|
+
| 总耗时 | `attributes.resource.timing.response_end − attributes.resource.timing.start_time` | 从请求开始到收到响应最后一个字节的总时长。 | 从这次请求开始,到浏览器收完全部内容为止。 | W3C:[Timing-Allow-Origin](https://www.w3.org/TR/resource-timing/#sec-timing-allow-origin) |
|
|
658
|
+
|
|
659
|
+
### c. 瀑布图
|
|
660
|
+
|
|
661
|
+
按 A→E 顺序匹配;所有瀑布图在基础图上进一步修改,标为「可选」的阶段按图下表格的显示条件绘制。
|
|
662
|
+
|
|
663
|
+
| 瀑布图类型 | 说明 | 判断条件 | 备注 |
|
|
664
|
+
| --- | --- | --- | --- |
|
|
665
|
+
| A. 跨域明细不可见 | 只能展示总耗时 | 以下条件同时满足:<br />[1] `attributes.resource.timing.request_start = 0`;<br />[2] `attributes.resource.timing.response_start = 0`;<br />[3] `attributes.resource.decoded_body_size = 0` | -- |
|
|
666
|
+
| B. Service Worker 响应 | 主请求由 SW 的 `fetch` 事件交回响应 | 以下条件同时满足:<br />[1] `attributes.resource.timing.worker_start > 0`;<br />[2] 以下条件满足任一:<br />[a] `attributes.resource.timing.connect_end = 0`<br />[b] `attributes.resource.timing.connect_end = attributes.resource.timing.fetch_start`<br />[3] 以下条件满足任一:<br />[a] `attributes.resource.timing.worker_matched_router_source = null`<br />[b] `attributes.resource.timing.worker_matched_router_source = fetch-event`<br />[4] `attributes.resource.timing.worker_final_router_source ≠ cache` | SW 转发网络时主请求也看不到 DNS、建连,真实网络耗时在 SW 内部请求上,所以不归 D / E。 |
|
|
667
|
+
| C. 非网络响应 | 主请求没有可见的 DNS、建连和 TLS 阶段 | 以下条件同时满足:<br />[1] 以下条件满足任一:<br />[a] `attributes.resource.timing.connect_end = 0`<br />[b] `attributes.resource.timing.connect_end = attributes.resource.timing.fetch_start`<br />[2] 以下条件满足任一:<br />[a] `attributes.resource.delivery_type = cache && attributes.resource.transfer_size = 0`(浏览器缓存命中)<br />[b] `attributes.resource.delivery_type = null && attributes.resource.transfer_size = 0 && attributes.resource.decoded_body_size > 0`(推断缓存命中)<br />[c] `attributes.resource.timing.worker_final_router_source = cache`(Service Worker 静态路由命中缓存) | [2][b] 用于未上报 `delivery_type` 的浏览器:没有传输字节但有正文,按缓存命中处理。 |
|
|
668
|
+
| D. 连接复用 | DNS、建连耗时为 `0` ms | 以下条件同时满足:<br />[1] `attributes.resource.timing.domain_lookup_start = attributes.resource.timing.domain_lookup_end = attributes.resource.timing.connect_start = attributes.resource.timing.connect_end`;<br />[2] `attributes.resource.timing.connect_end ≠ 0` | -- |
|
|
669
|
+
| E. 网络请求 | 普通请求、缓存重新验证等 | 以下条件同时满足:<br />[1] 未匹配 A、B、C、D 类;<br />[2] `attributes.resource.timing.connect_start > 0 && attributes.resource.timing.connect_end > 0` | -- |
|
|
566
670
|
|
|
567
|
-
|
|
671
|
+
图例:`=` 阶段条,`-` 浅色条,`·` 分隔线。
|
|
568
672
|
|
|
569
|
-
|
|
673
|
+
#### A. 明细不可见
|
|
570
674
|
|
|
571
|
-
|
|
675
|
+
**基础图**
|
|
572
676
|
|
|
573
|
-
|
|
677
|
+
```text
|
|
678
|
+
startTime responseEnd
|
|
679
|
+
------------------------------------------------ 总耗时
|
|
680
|
+
```
|
|
574
681
|
|
|
575
|
-
|
|
576
|
-
| --- | --- | --- |
|
|
577
|
-
| 1 | Queueing | 连接开始前排队:存在更高优先级请求,或同一源连接数已满 |
|
|
578
|
-
| 2 | Stalled | 连接开始后仍可能因 Queueing 同类原因停滞 |
|
|
579
|
-
| 3 | DNS Lookup | 解析域名对应的 IP |
|
|
580
|
-
| 4 | Initial connection | 建立连接,包含 TCP 握手和 TLS,不单列 TLS |
|
|
581
|
-
| 5 | Proxy negotiation | 与代理协商,仅走代理时出现 |
|
|
582
|
-
| 6 | Request sent | 正在发送 HTTP 请求 |
|
|
583
|
-
| 7 | ServiceWorker Preparation | 正在启动 Service Worker |
|
|
584
|
-
| 8 | Request to ServiceWorker | 请求交给 Service Worker |
|
|
585
|
-
| 9 | Waiting (TTFB) | 请求已发出,等待响应首字节。包含一趟网络往返和服务器准备时间 |
|
|
586
|
-
| 10 | Content Download | 读取响应体 |
|
|
682
|
+
#### B. Service Worker 响应
|
|
587
683
|
|
|
588
|
-
|
|
684
|
+
**基础图**
|
|
589
685
|
|
|
590
|
-
|
|
686
|
+
```text
|
|
687
|
+
startTime responseEnd
|
|
688
|
+
==== [资源调度] 正在排队
|
|
689
|
+
==== [ServiceWorker] 启动
|
|
690
|
+
= [ServiceWorker] 向 ServiceWorker 发送的请求(可选)
|
|
691
|
+
================= [ServiceWorker] respondWith
|
|
692
|
+
================= 等待首字节(可选)
|
|
693
|
+
====================== 内容下载
|
|
694
|
+
```
|
|
591
695
|
|
|
592
|
-
|
|
696
|
+
| 显示条件 | 阶段 | 说明 |
|
|
697
|
+
| --- | --- | --- |
|
|
698
|
+
| `requestStart > fetchStart` | [ServiceWorker] 向 ServiceWorker 发送的请求 | 通常为 `0` |
|
|
699
|
+
| `responseStart > 0` | 等待首字节 | 与 [ServiceWorker] respondWith 同起止。 |
|
|
593
700
|
|
|
594
|
-
|
|
701
|
+
> `responseStart = 0` (部分浏览器在 ServiceWorker 场景下,不记录 responseStart):「内容下载」改用 fetchStart -> responseEnd。
|
|
595
702
|
|
|
596
|
-
|
|
597
|
-
| --- | --- | --- | --- |
|
|
598
|
-
| 1 | Redirects | `redirectStart` / `redirectEnd` | HTTP 重定向 |
|
|
599
|
-
| 2 | DNS lookup | `domainLookupStart` / `domainLookupEnd` | DNS 解析 |
|
|
600
|
-
| 3 | Connection | `connectStart` → `secureConnectionStart` → `connectEnd` | 建连,HTTPS 时包含 TLS,TLS 耗时 = `connectEnd − secureConnectionStart` |
|
|
601
|
-
| 4 | Fetch | `fetchStart` | 开始取资源,会先查缓存 |
|
|
602
|
-
| 5 | Service worker | `workerStart` | 未拦截时为 `0` |
|
|
603
|
-
| 6 | Request | `requestStart` → `responseStart` | 发出请求到收到首字节 |
|
|
604
|
-
| 7 | Response | `responseStart` → `responseEnd` | 接收响应体 |
|
|
703
|
+
#### C. 非网络响应
|
|
605
704
|
|
|
606
|
-
|
|
705
|
+
**基础图**
|
|
607
706
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
707
|
+
```text
|
|
708
|
+
startTime responseEnd
|
|
709
|
+
======== 发起前等待
|
|
710
|
+
============ 等待首字节
|
|
711
|
+
============================ 内容下载
|
|
712
|
+
```
|
|
613
713
|
|
|
614
|
-
|
|
714
|
+
#### D. 连接复用
|
|
615
715
|
|
|
616
|
-
|
|
716
|
+
**基础图**
|
|
617
717
|
|
|
618
|
-
|
|
718
|
+
```text
|
|
719
|
+
startTime responseEnd
|
|
720
|
+
====== 重定向(可选)
|
|
721
|
+
==== 发起前等待
|
|
722
|
+
········ 连接复用:DNS、连接建立、TLS ········
|
|
723
|
+
==================== 等待首字节
|
|
724
|
+
================== 内容下载
|
|
725
|
+
```
|
|
619
726
|
|
|
620
|
-
|
|
727
|
+
> 为区分缓存场景,连接复用场景需要展示 DNS、建立连接、TLS 阶段
|
|
621
728
|
|
|
622
|
-
|
|
729
|
+
| 显示条件 | 阶段 | 说明 |
|
|
730
|
+
| --- | --- | --- |
|
|
731
|
+
| `redirectStart > 0` | 重定向 | 该请求经历重定向,最终一跳复用已有连接。 |
|
|
623
732
|
|
|
624
|
-
|
|
625
|
-
| --- | --- | --- | --- |
|
|
626
|
-
| 1 | 重定向 | 上报了 `redirect.start` 和 `redirect.duration` | `attributes.resource.redirect.duration` |
|
|
627
|
-
| 2 | 后台脚本处理 | 上报了 `worker.start` 和 `worker.duration` | `attributes.resource.worker.duration` |
|
|
628
|
-
| 3 | 查找服务器 | 始终占一行 | `attributes.resource.dns.duration` |
|
|
629
|
-
| 4 | 建立连接 | 始终占一行 | 有 `ssl` 时:`connect.duration − ssl.duration`<br />无 `ssl` 时:`connect.duration` |
|
|
630
|
-
| 5 | 加密连接 | 始终占一行 | `attributes.resource.ssl.duration` |
|
|
631
|
-
| 6 | 等待首字节 | 始终占一行 | `attributes.resource.first_byte.duration` |
|
|
632
|
-
| 7 | 下载内容 | 始终占一行 | `attributes.resource.download.duration` |
|
|
733
|
+
#### E. 网络请求
|
|
633
734
|
|
|
634
|
-
|
|
735
|
+
**基础图**
|
|
635
736
|
|
|
636
|
-
|
|
737
|
+
```text
|
|
738
|
+
startTime responseEnd
|
|
739
|
+
====== 重定向(可选)
|
|
740
|
+
=== 发起前等待
|
|
741
|
+
===== DNS(可选)
|
|
742
|
+
==== 连接建立(可选)
|
|
743
|
+
==== TLS(可选)
|
|
744
|
+
============ 等待首字节
|
|
745
|
+
============== 内容下载
|
|
746
|
+
```
|
|
637
747
|
|
|
638
|
-
|
|
|
748
|
+
| 显示条件 | 阶段 | 说明 |
|
|
639
749
|
| --- | --- | --- |
|
|
640
|
-
|
|
|
641
|
-
|
|
|
642
|
-
|
|
|
643
|
-
|
|
|
644
|
-
| 加密连接 | [a] TLS 握手,对应 `connectEnd − secureConnectionStart`<br />[b] 非 HTTPS、或未发生新握手时不上报 | [a] 内容尚未出现<br />[b] 用户无法感知「正在握手」,体验上仍是在等待 |
|
|
645
|
-
| 等待首字节 | [a] 从发出请求到收到响应首字节,对应 `responseStart − requestStart`<br />[b] 包含网络往返和服务端处理,浏览器时序无法拆分<br />[c] 对齐 Chrome Waiting (TTFB),范围小于 web.dev 的页面 TTFB | [a] 本次请求的内容仍不可见:页面持续白屏或停留在旧画面,接口持续 loading<br />[b] 过慢时会感觉页面没有反应 |
|
|
646
|
-
| 下载内容 | [a] 从收到首字节到响应体接收完毕,对应 `responseEnd − responseStart`<br />[b] 耗时主要随体积和带宽变化 | [a] 内容开始出现并逐渐完整,图片、脚本会陆续可见<br />[b] 接口数据会从空状态填到页面上<br />[c] 体积大时,用户能感到「出来了但还在加载」 |
|
|
750
|
+
| `redirectStart > 0` | 重定向 | 最终请求前发生可见重定向时展示。 |
|
|
751
|
+
| `domainLookupStart > 0` | DNS | DNS 使用缓存或复用现有解析结果时。 |
|
|
752
|
+
| `connectStart > 0` | 连接建立 | 有 TLS 时计算到 `secureConnectionStart`;两者相等时没有独立的连接建立条。 |
|
|
753
|
+
| `secureConnectionStart > 0` | TLS | 只有 `connectEnd − secureConnectionStart` 为正且时间点有效时才绘制;非零时间点本身不代表有握手阶段。 |
|
|
647
754
|
|
|
648
|
-
|
|
755
|
+
### d. 后续扩展
|
|
649
756
|
|
|
650
|
-
|
|
757
|
+
当前版本暂不展示,后续可按需补充:
|
|
651
758
|
|
|
652
|
-
|
|
|
653
|
-
| --- | --- |
|
|
654
|
-
| `
|
|
655
|
-
|
|
|
656
|
-
| 缺少 `start` 或 `duration` | 写「没有上报」,不画色块。可能该步骤未发生,也可能跨源不允许查看细分时间 |
|
|
657
|
-
|
|
658
|
-
查找服务器、建立连接、加密连接都没有上报时,写「没有上报」。跨源资源未暴露细分时间时表现相同,不能据此判断连接复用。
|
|
659
|
-
|
|
660
|
-
### e. 参考资料
|
|
661
|
-
|
|
662
|
-
| 来源 | 文档 |
|
|
663
|
-
| --- | --- |
|
|
664
|
-
| W3C | [Resource Timing](https://www.w3.org/TR/resource-timing/) |
|
|
665
|
-
| W3C | [Server Timing](https://www.w3.org/TR/server-timing/) |
|
|
666
|
-
| Chrome | [网络面板 · Timing](https://developer.chrome.com/docs/devtools/network/reference) |
|
|
667
|
-
| web.dev | [Navigation and Resource Timing](https://web.dev/articles/navigation-and-resource-timing) |
|
|
668
|
-
| web.dev | [Time to First Byte](https://web.dev/articles/ttfb) |
|
|
759
|
+
| 扩展 | 计算 | 生效条件 | 说明 |
|
|
760
|
+
| --- | --- | --- | --- |
|
|
761
|
+
| 临时响应 | `finalResponseHeadersStart − responseStart` | `firstInterimResponseStart > 0 && finalResponseHeadersStart > 0` | 服务器先回 `103` 等临时响应时,`responseStart` 指向首个临时响应,所以内容下载可拆成「临时响应」和「最终内容下载」两段。 |
|
|
762
|
+
| 最终内容下载 | `responseEnd − finalResponseHeadersStart` | 同上 | 从最终响应头到收完最后一个字节。|
|