@blueking/open-telemetry 0.0.14 → 0.0.16
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 +96 -641
- package/dist/bk-rum.global.js +9 -9
- package/dist/bk-rum.global.js.map +1 -1
- package/dist/core/action-activity.d.ts +28 -0
- package/dist/core/config.d.ts +113 -93
- package/dist/core/page-activity.d.ts +14 -0
- package/dist/core/plugin.d.ts +23 -6
- package/dist/core/processor.d.ts +25 -4
- package/dist/core/request-timing.d.ts +5 -0
- package/dist/core/runtime-context.d.ts +51 -3
- package/dist/core/sampling.d.ts +5 -1
- package/dist/core/sdk.d.ts +29 -10
- package/dist/core/url.d.ts +4 -1
- package/dist/index.d.ts +12 -14
- package/dist/index.js +2184 -1175
- package/dist/index.js.map +1 -1
- package/dist/plugins/action.d.ts +6 -2
- package/dist/plugins/activity.d.ts +6 -0
- package/dist/plugins/blank-screen.d.ts +17 -0
- package/dist/plugins/common.d.ts +11 -3
- package/dist/plugins/device.d.ts +2 -0
- package/dist/plugins/long-task.d.ts +3 -12
- package/dist/plugins/page-view.d.ts +1 -0
- package/dist/plugins/request-body.d.ts +14 -0
- package/dist/plugins/resource.d.ts +17 -1
- package/dist/plugins/session-state.d.ts +18 -0
- package/dist/plugins/session.d.ts +4 -4
- package/dist/plugins/web-vitals.d.ts +74 -0
- package/dist/schema/attributes.d.ts +31 -10
- package/dist/schema/span.d.ts +4 -12
- package/package.json +3 -7
- package/skills/bk-rum-otele/SKILL.md +39 -33
- package/skills/bk-rum-otele/evals/evals.json +3 -3
- package/skills/bk-rum-otele/references/api.md +247 -114
- package/skills/bk-rum-otele/references/architecture.md +141 -0
- package/skills/bk-rum-otele/references/capabilities.md +100 -0
- package/skills/bk-rum-otele/references/concepts.md +40 -111
- package/skills/bk-rum-otele/references/configuration.md +202 -254
- package/skills/bk-rum-otele/references/custom-plugin.md +22 -7
- package/skills/bk-rum-otele/references/data-model.md +17 -10
- package/skills/bk-rum-otele/references/framework-integration.md +25 -17
- package/skills/bk-rum-otele/references/getting-started.md +42 -86
- package/skills/bk-rum-otele/references/plugins.md +232 -138
- package/skills/bk-rum-otele/references/privacy.md +47 -34
- package/skills/bk-rum-otele/references/telemetry-reference.md +74 -45
- package/skills/bk-rum-otele/references/transport-sampling.md +79 -0
- package/skills/bk-rum-otele/references/troubleshooting.md +71 -37
- package/dist/plugins/http-body.d.ts +0 -3
- package/dist/plugins/route-timing.d.ts +0 -2
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# 隐私与公共属性
|
|
4
4
|
|
|
5
|
-
RUM 数据常包含 URL、用户标识、接口路径、错误信息和业务属性。SDK 不会替接入方猜测哪些字段敏感,因此提供 `privacy` 和 `
|
|
5
|
+
RUM 数据常包含 URL、用户标识、接口路径、错误信息和业务属性。SDK 不会替接入方猜测哪些字段敏感,因此提供 `privacy` 和 `context` 两类入口,由业务显式控制。
|
|
6
|
+
|
|
7
|
+
以下片段聚焦对应配置,实际初始化仍需提供必填的 `application.name` 和有效的 `transport` endpoint 配置。
|
|
6
8
|
|
|
7
9
|
## URL 脱敏
|
|
8
10
|
|
|
@@ -22,7 +24,7 @@ new BkOpenTelemetry({
|
|
|
22
24
|
|
|
23
25
|
## 属性脱敏
|
|
24
26
|
|
|
25
|
-
`privacy.redactAttributes`
|
|
27
|
+
`privacy.redactAttributes` 会处理通过 SDK `startSpan()`、`emitLog()` 以及内置插件显式应用的属性,适合删除 authorization、手机号、邮箱等字段。
|
|
26
28
|
|
|
27
29
|
```ts
|
|
28
30
|
new BkOpenTelemetry({
|
|
@@ -38,9 +40,13 @@ new BkOpenTelemetry({
|
|
|
38
40
|
});
|
|
39
41
|
```
|
|
40
42
|
|
|
43
|
+
第三方 OpenTelemetry instrumentation 自己生成的 Span 属性不保证经过这一构造路径。需要统一清理第三方 Span 时,在 `tracking.beforeSend` 做最终兜底;该 Hook 作用于 Span/Log,不作用于 Metric。
|
|
44
|
+
|
|
45
|
+
`redactAttributes` 应返回完整可用的属性对象,不要只返回被修改的单个字段。
|
|
46
|
+
|
|
41
47
|
## 公共属性
|
|
42
48
|
|
|
43
|
-
`attributes` 提供四类 hook:
|
|
49
|
+
`context.attributes` 提供四类 hook:
|
|
44
50
|
|
|
45
51
|
- `page`:页面、动作、错误等需要页面上下文的事件。
|
|
46
52
|
- `metric`:metric 维度,必须避免高基数字段。
|
|
@@ -49,20 +55,22 @@ new BkOpenTelemetry({
|
|
|
49
55
|
|
|
50
56
|
```ts
|
|
51
57
|
new BkOpenTelemetry({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
context: {
|
|
59
|
+
attributes: {
|
|
60
|
+
page: () => ({
|
|
61
|
+
'biz.space_id': window.__BK_SPACE_ID__,
|
|
62
|
+
'biz.project_id': window.__BK_PROJECT_ID__,
|
|
63
|
+
}),
|
|
64
|
+
metric: () => ({
|
|
65
|
+
'biz.app_code': 'bk-monitor',
|
|
66
|
+
}),
|
|
67
|
+
error: () => ({
|
|
68
|
+
'biz.release_channel': window.__BK_RELEASE_CHANNEL__,
|
|
69
|
+
}),
|
|
70
|
+
custom: () => ({
|
|
71
|
+
'biz.scene': 'checkout',
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
66
74
|
},
|
|
67
75
|
});
|
|
68
76
|
```
|
|
@@ -73,26 +81,29 @@ new BkOpenTelemetry({
|
|
|
73
81
|
|
|
74
82
|
```ts
|
|
75
83
|
new BkOpenTelemetry({
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
context: {
|
|
85
|
+
user: {
|
|
86
|
+
id: hashUserId(window.__BK_USER__?.id),
|
|
87
|
+
},
|
|
78
88
|
},
|
|
79
89
|
});
|
|
80
90
|
```
|
|
81
91
|
|
|
82
|
-
##
|
|
92
|
+
## 请求数据边界
|
|
83
93
|
|
|
84
|
-
`
|
|
94
|
+
SDK 默认不采集请求/响应 body。显式开启 `request.body` 时必须提供 `redact`,建议保持默认的 `capture: 'errors'`,并限制 Content-Type 和最大长度。
|
|
85
95
|
|
|
86
96
|
```ts
|
|
87
97
|
new BkOpenTelemetry({
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
tracking: {
|
|
99
|
+
request: {
|
|
100
|
+
body: {
|
|
101
|
+
capture: 'errors',
|
|
102
|
+
maxSize: 4096,
|
|
103
|
+
allowedContentTypes: ['application/json'],
|
|
104
|
+
redact: ({ body }) => {
|
|
93
105
|
return body.replace(/"password"\s*:\s*"[^"]+"/g, '"password":"***"');
|
|
94
|
-
}
|
|
95
|
-
return type === 'request' ? '[request body redacted]' : body;
|
|
106
|
+
},
|
|
96
107
|
},
|
|
97
108
|
},
|
|
98
109
|
},
|
|
@@ -105,12 +116,14 @@ new BkOpenTelemetry({
|
|
|
105
116
|
|
|
106
117
|
```ts
|
|
107
118
|
new BkOpenTelemetry({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
tracking: {
|
|
120
|
+
view: {
|
|
121
|
+
getPathGroup: url => {
|
|
122
|
+
const { pathname } = new URL(url, window.location.href);
|
|
123
|
+
return pathname
|
|
124
|
+
.replace(/\/\d+/g, '/:id')
|
|
125
|
+
.replace(/\/[0-9a-f]{24}/g, '/:objectId');
|
|
126
|
+
},
|
|
114
127
|
},
|
|
115
128
|
},
|
|
116
129
|
});
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
## 命名规则
|
|
10
10
|
|
|
11
11
|
- **信号名**:`browser.*` 表示内置浏览器事件(如 `browser.web_vital`);`action.<type>`、`custom.<name>` 是运行期动态拼接;`csp.violation`、`websocket.*` 使用领域前缀。
|
|
12
|
-
- **属性 key**:沿用 OpenTelemetry 语义约定的字段用点号(如 `http.request.method`、`exception.type`、`view.id`、`session.id`、`
|
|
12
|
+
- **属性 key**:沿用 OpenTelemetry 语义约定的字段用点号(如 `http.request.method`、`exception.type`、`view.id`、`session.id`、`browser.name`);跨类型检索字段使用下划线(如 `span_type`、`result`、`target_label`)。字段常量集中定义在 `src/schema/attributes.ts`。
|
|
13
13
|
|
|
14
14
|
## 公共上下文属性
|
|
15
15
|
|
|
@@ -17,45 +17,43 @@
|
|
|
17
17
|
|
|
18
18
|
| key | 类型 | 说明 | 低基数 |
|
|
19
19
|
| --- | --- | --- | --- |
|
|
20
|
-
| `service.name` | string | 应用名(`
|
|
21
|
-
| `service.version` | string | 应用版本(`
|
|
22
|
-
| `deployment.environment.name` | string | 环境(`
|
|
20
|
+
| `service.name` | string | 应用名(`application.name`) | 是 |
|
|
21
|
+
| `service.version` | string | 应用版本(`application.version`,可选) | 是 |
|
|
22
|
+
| `deployment.environment.name` | string | 环境(`application.environment`) | 是 |
|
|
23
23
|
| `rum.provider` | string | 固定 `blueking` | 是 |
|
|
24
24
|
| `telemetry.sdk.language` | string | 固定 `webjs` | 是 |
|
|
25
25
|
| `user.id` | string | 接入方提供,原样透传 | 否 |
|
|
26
26
|
| `session.id` | string | session 插件生成/轮换 | 否 |
|
|
27
27
|
| `session.has_replay` | boolean | 当前固定 `false` | 是 |
|
|
28
|
-
| `view.id` | string |
|
|
28
|
+
| `view.id` | string | View 管理器生成的实例 ID | 否 |
|
|
29
|
+
| `view.name` | string | 自动模式默认使用路由分组;手动模式可指定 | 是 |
|
|
29
30
|
| `view.url` | string | 当前 view URL(已脱敏) | 否 |
|
|
30
31
|
| `view.url_path_group` | string | 低基数路由模板 | 是 |
|
|
31
|
-
| `view.loading_type` | string | `initial_load` / `route_change` | 是 |
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
32
|
+
| `view.loading_type` | string | `initial_load` / `route_change` / `session_renewal` / `bf_cache` | 是 |
|
|
33
|
+
| `device.type` | string | `mobile` / `desktop` | 是 |
|
|
34
|
+
| `browser.name` / `browser.version` | string | 浏览器信息 | 是 |
|
|
35
|
+
| `os.name` | string | 操作系统 | 是 |
|
|
35
36
|
| `network.effective_type` | string | 网络质量(`4g` 等) | 是 |
|
|
36
37
|
|
|
37
|
-
> span 还会带上 `span_type` / `span_subtype` / `result` / `error_type` / `event_label` / `target_label` 等归一字段(见下方[归一字段](#归一字段)
|
|
38
|
+
> span 还会带上 `span_type` / `span_subtype` / `result` / `error_type` / `event_label` / `target_label` 等归一字段(见下方[归一字段](#归一字段))。接入方可通过 `context.attributes.page` 注入额外的页面属性。
|
|
38
39
|
|
|
39
40
|
## Span 清单
|
|
40
41
|
|
|
41
42
|
| span 名 | span_type | 来源 | 关键属性 | 备注 |
|
|
42
43
|
| --- | --- | --- | --- | --- |
|
|
43
|
-
| `browser.view` | `document` / `route` |
|
|
44
|
-
| `browser.
|
|
45
|
-
| `
|
|
46
|
-
| `documentLoad` / `documentFetch` / `resourceFetch` | `document` / `resource` | documentLoad instrumentation | `trace_scene=page_load` | span 名由官方探针决定 |
|
|
47
|
-
| `browser.resource` | `resource` | resource 插件 | `url.full`、`initiator_type`、`transfer_size`、`next_hop_protocol`、`cache_hit`、`resource.encoded_body_size`、`resource.decoded_body_size` | |
|
|
44
|
+
| `browser.view` | `document` / `route` | View 管理器 | `view.name`、`view.loading_time`、`view.loading_time.source`、`url.previous`、`event.source`、`view.end_reason` | 有持续时间,下一次 View 或 pagehide 时结束 |
|
|
45
|
+
| `browser.resource` | `resource` | Fetch/XHR request 采集 | `resource.type=fetch\|xhr`、`resource.url`、`resource.method`、`resource.status_code`、网络阶段属性 | span kind 为 CLIENT;Fetch/XHR 共用同一实现 |
|
|
46
|
+
| `browser.resource` | `resource` | resource 插件 | `resource.type`、`resource.url`、`resource.duration`、网络阶段、`resource.render_blocking_status`、`resource.protocol`、`resource.cache.hit` | 仅静态资源,跳过 Fetch/XHR |
|
|
48
47
|
| `browser.web_vital` | `vital` | webVitals 插件 | `vital.metric`、`vital.value`、`vital.rating`、`vital.id`、`rum.navigation.type`、`vital.<lcp\|cls\|inp\|fcp\|ttfb>.*` | 每个指标一条 |
|
|
49
|
-
| `browser.blank_screen` | `error` | blankScreen
|
|
48
|
+
| `browser.blank_screen` | `error` | blankScreen 插件(二次确认白屏时) | `blank_screen.empty_ratio`、`blank_screen.reason`、`blank_screen.root_selector`、`blank_screen.root_found`、`blank_screen.*_sample_count`、`blank_screen.center_element` | 每个 View 最多一条 |
|
|
50
49
|
| `browser.error` | `error` | error 插件(`window.error`) | `exception.*`、`error.source=window.error`、`error.window_count`、`code.filepath`、`code.lineno`、`code.column`、`error.cross_origin` | |
|
|
51
50
|
| `browser.unhandledrejection` | `error` | error 插件(Promise 异常) | `exception.*`、`error.source=unhandledrejection` | |
|
|
52
51
|
| `browser.resource_error` | `error` | error 插件(资源加载失败) | `exception.*`、`error.source=resource`、`url.full`、`html.tag` | |
|
|
53
|
-
| `browser.long_task` | `longtask` | longTask 插件 | `
|
|
54
|
-
| `browser.route_change` | `route` | routeTiming 插件 | `url.full`、`url.previous`、`route.change.source`、`target_value`(耗时) | |
|
|
52
|
+
| `browser.long_task` | `longtask` | longTask 插件 | `long_task.id`、`long_task.entry_type`、`long_task.start_time`、`long_task.duration`、`long_task.blocking_duration`、`long_task.culprit`、`long_task.script.count`、`target_value` | LoAF 脚本详情写入 `long_task.script` Span Event |
|
|
55
53
|
| `csp.violation` | `error` | cspViolation 插件 | `csp.blocked_uri`、`csp.violated_directive`、`csp.effective_directive`、`csp.source_file`、`csp.line_number`、`csp.status_code`、`csp.fingerprint`、`csp.window_count`、`csp.original_policy`(窗口首条) | |
|
|
56
54
|
| `websocket.connect` | `custom` | websocket 插件(仅建连阶段) | `url.full`、`url.scheme`、`server.address`、`network.protocol.name=websocket`、`target_domain` | 长连接生命周期不绑定 span |
|
|
57
|
-
| `action
|
|
58
|
-
| `custom.<name>` | `custom` | `reportCustomEvent()` / 自定义插件 | `rum.custom.name`、业务自定义属性 | 带 `error`
|
|
55
|
+
| `action.click` / `action.custom` | `action` | action 插件 / `reportAction()` | `action.id/name/type/target.*`、`action.loading_time`、`action.frustration.*`、`action.*.count` | 自动点击或手动动作;挫败信号仅自动点击 |
|
|
56
|
+
| `custom.<name>` | `custom` | `reportCustomEvent()` / 自定义插件 | `rum.custom.name`、业务自定义属性 | 带 `error` 时记录 exception、设置错误 Status/Result,`span_type` 仍为 `custom` |
|
|
59
57
|
|
|
60
58
|
## Metric 清单
|
|
61
59
|
|
|
@@ -63,16 +61,17 @@
|
|
|
63
61
|
| --- | --- | --- | --- | --- |
|
|
64
62
|
| `browser.web_vital.cls` | Histogram | `1` | `vital.metric`、`vital.rating`、`rum.navigation.type`、`view.url_path_group` | webVitals |
|
|
65
63
|
| `browser.web_vital.duration` | Histogram | `ms` | 同上(FCP/INP/LCP/TTFB 靠 `vital.metric` 区分) | webVitals |
|
|
66
|
-
| `browser.
|
|
67
|
-
| `browser.
|
|
64
|
+
| `browser.view.loading_time` | Histogram | `ms` | `view.url_path_group`、`view.loading_type` | View 管理器,View 结束时记录最终值 |
|
|
65
|
+
| `browser.blank_screen.count` | Counter | - | `view.url_path_group`、`blank_screen.root_selector`、`blank_screen.reason` | blankScreen |
|
|
66
|
+
| `browser.long_task.count` | Counter | - | `view.url_path_group`、`long_task.entry_type` | longTask |
|
|
68
67
|
| `browser.long_task.duration` | Histogram | `ms` | 同上 | longTask |
|
|
69
|
-
| `browser.
|
|
68
|
+
| `browser.long_task.blocking_duration` | Histogram | `ms` | 同上 | longTask,仅 LoAF |
|
|
70
69
|
| `browser.websocket.message.count` | Counter | - | `server.address`、`url.scheme`、`websocket.direction`(in/out) | websocket |
|
|
71
70
|
| `browser.websocket.message.bytes` | Counter | `By` | 同上 | websocket |
|
|
72
71
|
| `browser.websocket.error.count` | Counter | - | `server.address`、`url.scheme`、`websocket.error.phase`(connect/runtime) | websocket |
|
|
73
72
|
| `browser.websocket.connect.duration` | Histogram | `ms` | `server.address`、`url.scheme` | websocket,仅成功建连 |
|
|
74
73
|
|
|
75
|
-
> 各 metric
|
|
74
|
+
> 各 metric 只会合并 `context.attributes.metric` hook 返回的自定义低基数维度,不会合并 `context.attributes.page`,也不会携带 `session.id`、`view.id` 或 `action.id`。精确 View 关联请查询对应 span 或 View Snapshot Log。**metric 维度务必保持低基数**,不要把 URL、订单号、用户输入等放进来。
|
|
76
75
|
|
|
77
76
|
## Log 事件清单
|
|
78
77
|
|
|
@@ -80,8 +79,8 @@
|
|
|
80
79
|
| --- | --- | --- | --- |
|
|
81
80
|
| `session.start` | INFO | session 插件(首次新建) | `session.id`、`session.start_time`、`session.rotate.reason=init` |
|
|
82
81
|
| `session.rotate` | INFO | session 插件(轮换) | + `session.previous_id`、`session.rotate.reason`(`inactivity` / `maxLifetime`) |
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
82
|
+
| `browser.view` | INFO | View 管理器 | `view.snapshot.type=create\|update\|final`、`view.document_version`、`view.duration`、`view.is_active`、`view.loading_time` |
|
|
83
|
+
| `browser.request.body` | ERROR(错误请求)/ INFO(`capture: 'all'` 的成功请求) | Fetch/XHR request patch(仅显式配置 `request.body`) | `trace.id`、`span.id`、`request.body` / `response.body`、`*.body.content_type`、`*.body.truncated` |
|
|
85
84
|
| `websocket.error` | ERROR | websocket 插件 | `url.full`、`websocket.error.phase`、`websocket.error.window_count` |
|
|
86
85
|
| `websocket.close` | INFO | websocket 插件 | `websocket.close.code`、`websocket.close.reason`、`websocket.close.was_clean` |
|
|
87
86
|
|
|
@@ -95,7 +94,7 @@
|
|
|
95
94
|
|
|
96
95
|
| key | 类型 | 说明 | 低基数 |
|
|
97
96
|
| --- | --- | --- | --- |
|
|
98
|
-
| `span_type` | string | `document`/`
|
|
97
|
+
| `span_type` | string | `document`/`resource`/`vital`/`error`/`longtask`/`action`/`route`/`custom` | 是 |
|
|
99
98
|
| `span_subtype` | string | 子类型,如 `fetch`/`xhr`/`js`/`promise`/`lcp` | 是 |
|
|
100
99
|
| `result` | string | `success`/`warning`/`error`/`timeout`/`abort` | 是 |
|
|
101
100
|
| `error_type` | string | 错误细分,如 `http_5xx`/`network_timeout`/`slow`/`none` | 是 |
|
|
@@ -115,15 +114,30 @@
|
|
|
115
114
|
| `http.request.method` | string | 请求方法(大写) |
|
|
116
115
|
| `http.response.status_code` | number | 响应状态码 |
|
|
117
116
|
| `url.full` | string | 完整 URL(已脱敏) |
|
|
117
|
+
| `resource.type` | string | `fetch`/`xhr` 或静态资源 initiator type |
|
|
118
|
+
| `resource.url` | string | 资源 URL(已脱敏) |
|
|
119
|
+
| `resource.method` | string | 请求方法(Fetch/XHR) |
|
|
120
|
+
| `resource.status_code` | number | 请求状态码(Fetch/XHR) |
|
|
121
|
+
| `resource.duration` | number | 静态资源耗时(ms);请求耗时使用 Span 原生 duration |
|
|
122
|
+
| `resource.redirect.start/duration` | number | 重定向阶段相对开始时间 / 耗时(ms) |
|
|
123
|
+
| `resource.dns.start/duration` | number | DNS 阶段相对开始时间 / 耗时(ms) |
|
|
124
|
+
| `resource.connect.start/duration` | number | TCP 建连阶段相对开始时间 / 耗时(ms) |
|
|
125
|
+
| `resource.ssl.start/duration` | number | TLS 握手阶段相对开始时间 / 耗时(ms) |
|
|
126
|
+
| `resource.first_byte.start/duration` | number | 等待首字节阶段相对开始时间 / 耗时(ms) |
|
|
127
|
+
| `resource.download.start/duration` | number | 响应下载阶段相对开始时间 / 耗时(ms) |
|
|
128
|
+
| `resource.worker.start/duration` | number | Service Worker 阶段相对开始时间 / 耗时(ms) |
|
|
129
|
+
| `resource.delivery_type` | string | `cache` / `navigational-prefetch` 等浏览器交付类型 |
|
|
130
|
+
| `resource.render_blocking_status` | string | `blocking` / `non-blocking` |
|
|
131
|
+
| `resource.size` | number | 传输字节数 |
|
|
118
132
|
| `url.previous` | string | 跳转前 URL |
|
|
119
133
|
| `transfer_size` | number | 传输字节数 |
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
134
|
+
| `resource.cache.hit` | boolean | 是否命中缓存 |
|
|
135
|
+
| `resource.protocol` | string | 协议,如 `h2` |
|
|
122
136
|
| `initiator_type` | string | 资源发起类型 |
|
|
123
137
|
| `resource.encoded_body_size` / `resource.decoded_body_size` | number | 资源体积 |
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
138
|
+
| `request.body` / `response.body` | string | 仅 `browser.request.body` Log;经过接入方 `redact` 且受长度限制 |
|
|
139
|
+
| `request.body.content_type` / `response.body.content_type` | string | body Content-Type(可获取时) |
|
|
140
|
+
| `request.body.truncated` / `response.body.truncated` | boolean | body 是否因长度限制而截断 |
|
|
127
141
|
|
|
128
142
|
### Web Vitals
|
|
129
143
|
|
|
@@ -157,21 +171,30 @@
|
|
|
157
171
|
|
|
158
172
|
| key | 类型 | 说明 |
|
|
159
173
|
| --- | --- | --- |
|
|
160
|
-
| `device.id` | string |
|
|
174
|
+
| `device.id` | string | 匿名设备标识;默认仅当前 SDK 实例稳定,`tracking.device.persistentId=true` 时持久化 |
|
|
161
175
|
| `device.memory` / `device.cpu_cores` | number | 硬件能力 |
|
|
162
176
|
| `device.platform` / `device.mobile` | string/bool | UA-CH 平台信息 |
|
|
163
177
|
| `browser.viewport.width` / `browser.viewport.height` | number | 视口尺寸 |
|
|
164
178
|
| `browser.screen.width` / `browser.screen.height` | number | 屏幕尺寸 |
|
|
165
179
|
| `network.connection_type` / `network.downlink` / `network.rtt` / `network.save_data` | mixed | 网络信息 |
|
|
166
|
-
| `
|
|
180
|
+
| `browser.name` / `browser.version` / `os.name` | string | UA 解析结果 |
|
|
181
|
+
| `device.type` | string | `mobile` / `desktop` |
|
|
167
182
|
|
|
168
183
|
### 用户动作 / 会话
|
|
169
184
|
|
|
170
185
|
| key | 类型 | 说明 |
|
|
171
186
|
| --- | --- | --- |
|
|
172
187
|
| `action.type` | string | 动作类型 |
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
188
|
+
| `action.id` | string / string[] | action 自身 ID;关联事件上为 action ID 数组 |
|
|
189
|
+
| `action.name` | string | 可读动作名称 |
|
|
190
|
+
| `action.target.name` | string | 自动 action 的目标元素名称 |
|
|
191
|
+
| `action.target.tag` | string | 自动 action 的目标元素标签 |
|
|
192
|
+
| `action.loading_time` | number | 点击后页面活动稳定耗时(ms) |
|
|
193
|
+
| `action.resource.count` | number | action 关联资源数 |
|
|
194
|
+
| `action.error.count` | number | action 关联错误数 |
|
|
195
|
+
| `action.long_task.count` | number | action 关联长任务数 |
|
|
196
|
+
| `action.frustration.type` | string[] | `rage_click` / `dead_click` / `error_click` |
|
|
197
|
+
| `action.frustration.count` | number | 当前 action 的挫败信号数量 |
|
|
175
198
|
| `session.start_time` | number | 会话开始时间戳 |
|
|
176
199
|
| `session.previous_id` | string | 轮换前的 session.id |
|
|
177
200
|
| `session.rotate.reason` | string | `init`/`inactivity`/`maxLifetime` |
|
|
@@ -180,8 +203,15 @@
|
|
|
180
203
|
|
|
181
204
|
| key | 类型 | 说明 |
|
|
182
205
|
| --- | --- | --- |
|
|
183
|
-
| `
|
|
184
|
-
| `
|
|
206
|
+
| `long_task.id` | string | 长任务或长动画帧 ID |
|
|
207
|
+
| `long_task.entry_type` | string | `long-animation-frame` / `long-task` |
|
|
208
|
+
| `long_task.start_time` | number | LoAF 相对 `performance.timeOrigin` 的开始时间(ms) |
|
|
209
|
+
| `long_task.duration` / `long_task.blocking_duration` | number | 总耗时 / 主线程阻塞耗时(ms) |
|
|
210
|
+
| `long_task.is_frozen_frame` | boolean | 总耗时是否达到 700ms |
|
|
211
|
+
| `long_task.culprit` | string | 最重脚本 URL、函数或 legacy attribution |
|
|
212
|
+
| `long_task.script.count` | number | LoAF 脚本数 |
|
|
213
|
+
| `long_task.render_start` / `long_task.style_and_layout_start` | number | LoAF 渲染与样式布局阶段起点 |
|
|
214
|
+
| `long_task.script.*` | mixed | `long_task.script` Span Event 上的脚本耗时、URL、函数、invoker 和强制布局归因 |
|
|
185
215
|
|
|
186
216
|
### CSP
|
|
187
217
|
|
|
@@ -212,17 +242,16 @@
|
|
|
212
242
|
|
|
213
243
|
| key | 类型 | 说明 |
|
|
214
244
|
| --- | --- | --- |
|
|
215
|
-
| `blank_screen.
|
|
216
|
-
| `blank_screen.
|
|
217
|
-
| `blank_screen.
|
|
218
|
-
| `blank_screen.
|
|
219
|
-
| `blank_screen.
|
|
245
|
+
| `blank_screen.empty_ratio` | number | 有效样本中的空白比例 |
|
|
246
|
+
| `blank_screen.reason` | string | `empty_viewport` / `missing_root` |
|
|
247
|
+
| `blank_screen.root_selector` / `blank_screen.root_found` | string/boolean | 根选择器与是否存在 |
|
|
248
|
+
| `blank_screen.sample_count` / `blank_screen.valid_sample_count` | number | 总样本数 / 有效样本数 |
|
|
249
|
+
| `blank_screen.empty_sample_count` / `blank_screen.ignored_sample_count` | number | 空白样本数 / loading 忽略样本数 |
|
|
220
250
|
| `blank_screen.center_element` | string | 视口中心元素选择器 |
|
|
221
|
-
| `blank_screen.dom_node_count` | number | body 下 DOM 节点总数 |
|
|
222
251
|
|
|
223
252
|
### 自定义事件
|
|
224
253
|
|
|
225
254
|
| key | 类型 | 说明 |
|
|
226
255
|
| --- | --- | --- |
|
|
227
256
|
| `rum.custom.name` | string | `reportCustomEvent()` 的事件名 |
|
|
228
|
-
| `rum.page.host` / `rum.page.path` | string | 默认 `attributes.page`
|
|
257
|
+
| `rum.page.host` / `rum.page.path` | string | 默认 `context.attributes.page` 页面上下文;配置自定义 page hook 后由接入方决定字段 |
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!-- 本文件由 packages/open-telemetry/scripts/gen-skill-references.mjs 从 wikis 自动生成,请勿手改。 -->
|
|
2
|
+
|
|
3
|
+
# 传输与采样
|
|
4
|
+
|
|
5
|
+
## Endpoint
|
|
6
|
+
|
|
7
|
+
`transport.endpoint` 是可选根地址。未配置独立地址的已开启信号会基于它生成 `/v1/rum`、`/v1/metrics`、`/v1/logs`;单信号 `endpoint` 是完整 URL,不再拼接路径。
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
new BkOpenTelemetry({
|
|
11
|
+
application: { name: 'demo' },
|
|
12
|
+
transport: {
|
|
13
|
+
endpoint: 'https://collector.example.com',
|
|
14
|
+
token: 'report-token',
|
|
15
|
+
signals: {
|
|
16
|
+
traces: {
|
|
17
|
+
endpoint: 'https://trace.example.com/v1/rum',
|
|
18
|
+
processor: 'batch',
|
|
19
|
+
batch: {
|
|
20
|
+
maxQueueSize: 2048,
|
|
21
|
+
maxExportBatchSize: 512,
|
|
22
|
+
scheduledDelayMillis: 5000,
|
|
23
|
+
exportTimeoutMillis: 30000,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
metrics: { endpoint: 'https://metric.example.com/v1/metrics', intervalMillis: 60_000 },
|
|
27
|
+
logs: { endpoint: 'https://log.example.com/v1/logs' },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 独立信号开关
|
|
34
|
+
|
|
35
|
+
三类信号默认全部开启。设为 `false` 时,不创建对应 exporter、processor 或 metric reader:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
new BkOpenTelemetry({
|
|
39
|
+
application: { name: 'trace-only-demo' },
|
|
40
|
+
transport: {
|
|
41
|
+
signals: {
|
|
42
|
+
traces: { endpoint: 'https://trace.example.com/v1/rum' },
|
|
43
|
+
metrics: false,
|
|
44
|
+
logs: false,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
校验规则:
|
|
51
|
+
|
|
52
|
+
- 至少开启一种信号,三类不能全部为 `false`。
|
|
53
|
+
- 每个开启信号必须有独立 endpoint,或能回退到根 `transport.endpoint`。
|
|
54
|
+
- 关闭 Trace 后不记录 Span,也不会向 `allowedTracingUrls` 注入 `traceparent`。
|
|
55
|
+
- 关闭 Metric 后不启动周期导出定时器。
|
|
56
|
+
- 关闭 Log 不影响 Session/View 上下文维护,但不会产生 Session、View Snapshot、HTTP body 等 Log。
|
|
57
|
+
|
|
58
|
+
只开启 Metric 时没有精确 `view.id` 下钻链路;需要从指标定位具体 View 时,至少开启 Trace。
|
|
59
|
+
|
|
60
|
+
请求头优先级:`token` 生成的 Authorization < `transport.headers` < 单 signal `headers`。
|
|
61
|
+
|
|
62
|
+
浏览器 OTLP HTTP exporter 负责实际传输,SDK 在 `pagehide` 和页面进入 hidden 时触发 flush。`shutdown()` 会先结束 View 和插件,再 flush final Snapshot,最后关闭 provider。
|
|
63
|
+
|
|
64
|
+
## Session 级确定性采样
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
new BkOpenTelemetry({
|
|
68
|
+
application: { name: 'demo' },
|
|
69
|
+
transport: { endpoint: 'https://collector.example.com' },
|
|
70
|
+
session: { sampleRate: 0.05 },
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- `1` 表示全量,`0` 表示全部丢弃。
|
|
75
|
+
- 决定由 `application.name + session.id` 的稳定 hash 得出。
|
|
76
|
+
- 采样决定不写额外 storage;同一 Session 内 span/log/metric 决定一致。
|
|
77
|
+
- Session 续期后使用新 ID 重新计算。
|
|
78
|
+
|
|
79
|
+
Metric exporter 只接受带内部采样标记的数据点,并在传输前移除该标记。Metric 只保留低基数 `view.url_path_group`,精确 View 关联由 span/log/View Snapshot 的 `view.id` 提供。
|