@blueking/open-telemetry 0.0.18 → 0.0.20
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 +1 -1
- package/dist/bk-rum.global.js +2 -2
- package/dist/bk-rum.global.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +765 -844
- package/dist/index.js.map +1 -1
- package/dist/plugins/device.d.ts +4 -3
- package/dist/plugins/resource.d.ts +0 -1
- package/dist/plugins/web-vitals.d.ts +11 -11
- package/dist/schema/attributes.d.ts +3 -9
- package/dist/schema/span.d.ts +5 -15
- package/package.json +1 -1
- package/skills/bk-rum-otele/SKILL.md +2 -2
- package/skills/bk-rum-otele/references/api.md +1 -11
- package/skills/bk-rum-otele/references/architecture.md +1 -1
- package/skills/bk-rum-otele/references/capabilities.md +2 -2
- package/skills/bk-rum-otele/references/concepts.md +0 -4
- package/skills/bk-rum-otele/references/configuration.md +2 -2
- package/skills/bk-rum-otele/references/data-model.md +2 -20
- package/skills/bk-rum-otele/references/plugins.md +5 -5
- package/skills/bk-rum-otele/references/privacy.md +1 -1
- package/skills/bk-rum-otele/references/telemetry-reference.md +37 -46
package/dist/plugins/device.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { BkOTPlugin } from '../core/plugin';
|
|
2
|
+
import type { Attributes } from '@opentelemetry/api';
|
|
2
3
|
export interface BkOTDevicePluginOptions {
|
|
3
4
|
/** 是否跨页面持久化匿名设备 ID,默认 false。 */
|
|
4
5
|
persistentId?: boolean;
|
|
5
6
|
storageKey?: string;
|
|
6
7
|
}
|
|
8
|
+
export declare const getDeviceResourceAttributes: () => Attributes;
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
* 让所有 log/span 都自动带上这些维度。
|
|
10
|
+
* 设备元数据采集插件。稳定的设备能力由 SDK 写入 Resource;这里只维护设备 ID 和运行期动态属性。
|
|
10
11
|
*
|
|
11
12
|
* 上报字段:
|
|
12
13
|
* - `device.id`:设备级永久标识,存于 localStorage(默认 key 复用旧 session 插件以保留现网用户)。
|
|
13
|
-
* - `device.
|
|
14
|
+
* - `device.memory_gib` / `device.logical_processor_count`:硬件能力快照,写入 Resource。
|
|
14
15
|
* - `browser.viewport.*` / `browser.screen.*`:视口与屏幕尺寸。
|
|
15
16
|
* - `network.effective_type` / `network.connection_type` / `network.downlink` / `network.rtt` / `network.save_data`:
|
|
16
17
|
* 网络信息。
|
|
@@ -14,7 +14,6 @@ export declare const getResourcePerformanceAttributes: (entry: ResourceTimingWit
|
|
|
14
14
|
'resource.decoded_body_size': number;
|
|
15
15
|
'resource.render_blocking_status'?: string | undefined;
|
|
16
16
|
'resource.delivery_type'?: string | undefined;
|
|
17
|
-
transfer_size: number;
|
|
18
17
|
"resource.cache.hit": boolean | undefined;
|
|
19
18
|
"resource.protocol": string;
|
|
20
19
|
};
|
|
@@ -37,6 +37,15 @@ interface EventTimingEntry extends PerformanceEntry {
|
|
|
37
37
|
processingStart?: number;
|
|
38
38
|
target?: EventTarget | null;
|
|
39
39
|
}
|
|
40
|
+
interface InpCandidate {
|
|
41
|
+
duration: number;
|
|
42
|
+
inputDelay: number;
|
|
43
|
+
interactionId: number;
|
|
44
|
+
interactionTarget?: string;
|
|
45
|
+
interactionType: string;
|
|
46
|
+
presentationDelay: number;
|
|
47
|
+
processingDuration: number;
|
|
48
|
+
}
|
|
40
49
|
interface LayoutShiftEntry extends PerformanceEntry {
|
|
41
50
|
hadRecentInput?: boolean;
|
|
42
51
|
sources?: Array<{
|
|
@@ -51,25 +60,16 @@ interface ViewVitalState {
|
|
|
51
60
|
clsWindowLargestShiftValue: number;
|
|
52
61
|
clsWindowStart?: number;
|
|
53
62
|
clsWindowValue: number;
|
|
63
|
+
id: string;
|
|
64
|
+
inpCandidates: InpCandidate[];
|
|
54
65
|
interactionCountAtStart?: number;
|
|
55
66
|
interactionIdMax: number;
|
|
56
67
|
interactionIdMin: number;
|
|
57
|
-
inpCandidates: InpCandidate[];
|
|
58
|
-
id: string;
|
|
59
68
|
largestShiftTarget?: string;
|
|
60
69
|
largestShiftValue: number;
|
|
61
70
|
runtimeAttributes: Attributes;
|
|
62
71
|
startedAt: number;
|
|
63
72
|
}
|
|
64
|
-
interface InpCandidate {
|
|
65
|
-
duration: number;
|
|
66
|
-
inputDelay: number;
|
|
67
|
-
interactionId: number;
|
|
68
|
-
interactionTarget?: string;
|
|
69
|
-
interactionType: string;
|
|
70
|
-
presentationDelay: number;
|
|
71
|
-
processingDuration: number;
|
|
72
|
-
}
|
|
73
73
|
export declare const isSameViewId: (currentViewId: string | undefined, nextViewId: string | undefined) => boolean;
|
|
74
74
|
export declare const updateViewCls: (view: ViewVitalState, entry: LayoutShiftEntry) => void;
|
|
75
75
|
export declare const updateViewInp: (view: ViewVitalState, entry: EventTimingEntry) => void;
|
|
@@ -19,10 +19,10 @@ export declare const RUM_ATTRIBUTES: {
|
|
|
19
19
|
readonly browserName: "browser.name";
|
|
20
20
|
readonly browserVersion: "browser.version";
|
|
21
21
|
readonly cacheHit: "resource.cache.hit";
|
|
22
|
+
readonly deviceLogicalProcessorCount: "device.logical_processor_count";
|
|
23
|
+
readonly deviceMemoryGib: "device.memory_gib";
|
|
22
24
|
readonly deviceType: "device.type";
|
|
23
|
-
readonly durationBucket: "duration_bucket";
|
|
24
25
|
readonly errorType: "error_type";
|
|
25
|
-
readonly eventLabel: "event_label";
|
|
26
26
|
readonly exceptionFingerprint: "exception.fingerprint";
|
|
27
27
|
readonly exceptionMessageShort: "exception.message_short";
|
|
28
28
|
readonly exceptionStackTopFrame: "exception.stack_top_frame";
|
|
@@ -37,6 +37,7 @@ export declare const RUM_ATTRIBUTES: {
|
|
|
37
37
|
readonly networkEffectiveType: "network.effective_type";
|
|
38
38
|
readonly nextHopProtocol: "resource.protocol";
|
|
39
39
|
readonly result: "result";
|
|
40
|
+
readonly rumSchemaVersion: "rum.schema.version";
|
|
40
41
|
readonly serviceName: "service.name";
|
|
41
42
|
readonly serviceVersion: "service.version";
|
|
42
43
|
readonly osName: "os.name";
|
|
@@ -45,13 +46,6 @@ export declare const RUM_ATTRIBUTES: {
|
|
|
45
46
|
readonly sessionStartTime: "session.start_time";
|
|
46
47
|
readonly spanSubtype: "span_subtype";
|
|
47
48
|
readonly spanType: "span_type";
|
|
48
|
-
readonly statusClass: "status_class";
|
|
49
|
-
readonly targetDomain: "target_domain";
|
|
50
|
-
readonly targetLabel: "target_label";
|
|
51
|
-
readonly targetPathTemplate: "target_path_template";
|
|
52
|
-
readonly targetValue: "target_value";
|
|
53
|
-
readonly traceScene: "trace_scene";
|
|
54
|
-
readonly transferSize: "transfer_size";
|
|
55
49
|
readonly userId: "user.id";
|
|
56
50
|
readonly vitalMetric: "vital.metric";
|
|
57
51
|
readonly vitalRating: "vital.rating";
|
package/dist/schema/span.d.ts
CHANGED
|
@@ -17,38 +17,28 @@ export declare const RUM_SPAN_TYPE: {
|
|
|
17
17
|
readonly vital: "vital";
|
|
18
18
|
};
|
|
19
19
|
export interface RumResourceSpanInput {
|
|
20
|
-
duration?: number;
|
|
21
20
|
initiatorType?: string;
|
|
22
21
|
method?: string;
|
|
23
22
|
networkError?: boolean;
|
|
24
23
|
responseStatus?: number;
|
|
25
24
|
transferSize?: number;
|
|
26
25
|
url: string;
|
|
27
|
-
urlPathTemplate?: string;
|
|
28
26
|
}
|
|
29
27
|
export interface RumSpanClassification {
|
|
30
|
-
duration?: number;
|
|
31
28
|
errorType?: string;
|
|
32
|
-
eventLabel?: string;
|
|
33
29
|
result?: RumSpanResult;
|
|
34
30
|
spanSubtype: string;
|
|
35
31
|
spanType: RumSpanType;
|
|
36
|
-
targetLabel?: string;
|
|
37
|
-
targetValue?: boolean | number | string;
|
|
38
|
-
traceScene?: string;
|
|
39
32
|
}
|
|
40
33
|
export type RumSpanResult = (typeof RUM_SPAN_RESULT)[keyof typeof RUM_SPAN_RESULT];
|
|
41
34
|
export type RumSpanType = (typeof RUM_SPAN_TYPE)[keyof typeof RUM_SPAN_TYPE];
|
|
42
35
|
export interface RumUrlTarget {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
pathTemplate?: string;
|
|
36
|
+
serverAddress?: string;
|
|
37
|
+
serverPort?: number;
|
|
46
38
|
}
|
|
47
|
-
export declare const getDurationBucket: (duration: number) => "<100ms" | "100~500ms" | "500ms~2s" | ">2s";
|
|
48
|
-
export declare const getStatusClass: (statusCode: number) => string;
|
|
49
39
|
export declare const getHttpResult: (statusCode: number | undefined) => RumSpanResult;
|
|
50
40
|
export declare const getHttpErrorType: (statusCode: number | undefined) => "none" | "network_timeout" | "http_5xx" | "http_4xx";
|
|
51
41
|
export declare const getVitalResult: (rating: string | undefined) => RumSpanResult;
|
|
52
|
-
export declare const getUrlTarget: (url: string | undefined
|
|
53
|
-
export declare const buildRumSpanAttributes: ({
|
|
54
|
-
export declare const buildRumResourceSpanAttributes: ({
|
|
42
|
+
export declare const getUrlTarget: (url: string | undefined) => RumUrlTarget;
|
|
43
|
+
export declare const buildRumSpanAttributes: ({ errorType, result, spanSubtype, spanType, }: RumSpanClassification) => Attributes;
|
|
44
|
+
export declare const buildRumResourceSpanAttributes: ({ initiatorType, method, networkError, responseStatus, transferSize, url, }: RumResourceSpanInput) => Attributes;
|
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@ description: 帮助业务方在前端应用里接入、使用和配置蓝鲸 RUM
|
|
|
32
32
|
| 查公开 API(start/flush/shutdown/setUser/setView/reportAction/reportCustomEvent 等) | `references/api.md` |
|
|
33
33
|
| Vue / React / Vue Router / 微前端 集成 | `references/framework-integration.md` |
|
|
34
34
|
| URL 脱敏、属性脱敏、公共属性、低基数路由、user.id 处理 | `references/privacy.md` |
|
|
35
|
-
| 了解上报字段、span_type/result
|
|
35
|
+
| 了解上报字段、span_type/result、哪些字段是后端派生 | `references/data-model.md` |
|
|
36
36
|
| 查具体的 span 名 / metric 名 / log 事件名、完整属性字典 | `references/telemetry-reference.md` |
|
|
37
37
|
| 本地看不到数据、手动事件没上报、白屏误报、接口 span 太多等排障 | `references/troubleshooting.md` |
|
|
38
38
|
|
|
@@ -63,7 +63,7 @@ SDK 维护公共上下文并自动挂到后续 span/log 上:`user.id`(业务
|
|
|
63
63
|
|
|
64
64
|
### 数据归一
|
|
65
65
|
|
|
66
|
-
SDK 为 span 补充归一字段便于统一检索:`span_type`(document/resource/vital/error/longtask/action/route/custom)、`result`(success/warning/error/timeout/abort)、`
|
|
66
|
+
SDK 为 span 补充归一字段便于统一检索:`span_type`(document/resource/vital/error/longtask/action/route/custom)、`span_subtype`、`result`(success/warning/error/timeout/abort)、`error_type`。Fetch/XHR 与静态资源统一为 resource,通过 `resource.type` 区分。
|
|
67
67
|
|
|
68
68
|
## 最小接入速查
|
|
69
69
|
|
|
@@ -261,10 +261,7 @@ const plugin = createPlugin({
|
|
|
261
261
|
归一字段 key 常量。
|
|
262
262
|
|
|
263
263
|
```ts
|
|
264
|
-
|
|
265
|
-
name: 'biz_event',
|
|
266
|
-
attributes: { [RUM_ATTRIBUTES.targetLabel]: 'submit-order' },
|
|
267
|
-
});
|
|
264
|
+
const spanTypeKey = RUM_ATTRIBUTES.spanType; // 'span_type'
|
|
268
265
|
```
|
|
269
266
|
|
|
270
267
|
### RUM_SPAN_TYPE / RUM_SPAN_RESULT
|
|
@@ -278,18 +275,11 @@ const span = bkOT.startSpan('custom.cache_hit', {
|
|
|
278
275
|
...buildRumSpanAttributes({
|
|
279
276
|
spanType: RUM_SPAN_TYPE.custom,
|
|
280
277
|
spanSubtype: 'cache',
|
|
281
|
-
eventLabel: '业务缓存',
|
|
282
|
-
targetLabel: 'homepage',
|
|
283
|
-
targetValue: true,
|
|
284
278
|
}),
|
|
285
279
|
});
|
|
286
280
|
span.end();
|
|
287
281
|
```
|
|
288
282
|
|
|
289
|
-
### getDurationBucket(duration)
|
|
290
|
-
|
|
291
|
-
返回 `<100ms`、`100~500ms`、`500ms~2s`、`>2s` 之一。
|
|
292
|
-
|
|
293
283
|
### buildRumSpanAttributes 相关类型
|
|
294
284
|
|
|
295
285
|
公开 `RumSpanClassification`、`RumSpanType`、`RumSpanResult`,用于扩展插件保持同一归一模型。
|
|
@@ -123,7 +123,7 @@ Fetch/XHR 由 `createCommonInstrumentationsPlugin()` 的单一生命周期直接
|
|
|
123
123
|
| 入口 | 作用范围 | 适合用途 |
|
|
124
124
|
| --- | --- | --- |
|
|
125
125
|
| `privacy.redactUrl` | SDK 写入的 URL 类属性 | 删除 query/hash、模板化路径 |
|
|
126
|
-
| `privacy.redactAttributes` |
|
|
126
|
+
| `privacy.redactAttributes` | Resource、通过 SDK `startSpan()`、`emitLog()` 和内置插件显式应用的属性 | 删除敏感业务字段 |
|
|
127
127
|
| `tracking.request.beforeSend` | 单个 Fetch/XHR,带原始 Request/Response/XHR 上下文 | 请求专属补充或丢弃 |
|
|
128
128
|
| Request Body `redact` | 单个请求/响应 Body,必填 | 内容级脱敏;返回 `undefined` 跳过该 Body |
|
|
129
129
|
| `tracking.beforeSend` | Span/Log 进入底层 processor 前 | 最终兜底修改或丢弃;不作用于 Metric |
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
| 手动 Action | `reportAction()` | 可调用 | 业务调用 | `action.custom` | — | — |
|
|
19
19
|
| 自定义事件 | `reportCustomEvent()` | 可调用 | 业务调用 | `custom.<name>` | — | — |
|
|
20
20
|
| 白屏 | `tracking.blankScreen` | 开 | DOM 命中测试、View 活动 | `browser.blank_screen` | `browser.blank_screen.count` | — |
|
|
21
|
-
| 设备 | `tracking.device` | 开 | UA、UA-CH、Screen、Network Information |
|
|
21
|
+
| 设备 | `tracking.device` | 开 | UA、UA-CH、Screen、Network Information | Resource 与运行时公共属性 | — | Resource 与运行时公共属性 |
|
|
22
22
|
| Long Task | `tracking.longTask` | 关 | Long Animation Frames / Long Tasks | `browser.long_task` | 三个聚合指标 | — |
|
|
23
23
|
| WebSocket | `tracking.websocket` | 关 | `WebSocket` Proxy | `websocket.connect` | 四个聚合指标 | error / close |
|
|
24
24
|
| CSP | `tracking.cspViolation` | 关 | `securitypolicyviolation` | `csp.violation` | — | — |
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
- 创建和轮换 Session,划分初始加载、SPA、BFCache、手动和 Session 续期 View。
|
|
35
35
|
- 统一 patch Fetch/XHR;请求 span、活动计数、Trace Header、Resource Timing 和 Body 采集共用同一生命周期。
|
|
36
|
-
- 把浏览器事件归一为 `span_type`、`result`、`error_type
|
|
36
|
+
- 把浏览器事件归一为 `span_type`、`span_subtype`、`result`、`error_type` 等字段。
|
|
37
37
|
- 自动为 Span/Log 关联 `session.id`、`view.id`,为 Metric 保留低基数 `view.url_path_group`。
|
|
38
38
|
- 在 exporter 前执行采样、有效上下文、自上报请求和 `tracking.beforeSend` 过滤。
|
|
39
39
|
|
|
@@ -103,8 +103,6 @@ SDK 会为 span 补充 RUM 归一字段,例如:
|
|
|
103
103
|
|
|
104
104
|
- `span_type`:`document`、`resource`、`vital`、`error`、`longtask`、`action`、`route`、`custom`
|
|
105
105
|
- `result`:`success`、`warning`、`error`、`timeout`、`abort`
|
|
106
|
-
- `duration_bucket`:`<100ms`、`100~500ms`、`500ms~2s`、`>2s`
|
|
107
|
-
- `target_label`:跨类型的主标签,用于统一检索
|
|
108
106
|
|
|
109
107
|
示例:自定义 span 也可以复用归一字段构造器。
|
|
110
108
|
|
|
@@ -115,8 +113,6 @@ const span = bkOT.startSpan('custom.cache_warmup', {
|
|
|
115
113
|
...buildRumSpanAttributes({
|
|
116
114
|
spanType: RUM_SPAN_TYPE.custom,
|
|
117
115
|
spanSubtype: 'cache_warmup',
|
|
118
|
-
eventLabel: '缓存预热',
|
|
119
|
-
targetLabel: 'homepage',
|
|
120
116
|
}),
|
|
121
117
|
});
|
|
122
118
|
|
|
@@ -38,7 +38,7 @@ const bkOT = new BkOpenTelemetry(options);
|
|
|
38
38
|
| `environment` | `string` | `production` | `deployment.environment.name` |
|
|
39
39
|
| `version` | `string` | 无 | `service.version` |
|
|
40
40
|
|
|
41
|
-
SDK 还会固定写入 `rum.
|
|
41
|
+
SDK 还会固定写入 `rum.schema.version=2`、`telemetry.sdk.name=@blueking/open-telemetry`、`telemetry.sdk.language=webjs` 和当前包版本 `telemetry.sdk.version`。默认启用 `tracking.device` 时,浏览器、OS 和稳定的硬件能力也会写入 Resource。
|
|
42
42
|
|
|
43
43
|
## transport
|
|
44
44
|
|
|
@@ -216,7 +216,7 @@ tracking: {
|
|
|
216
216
|
| --- | --- | --- | --- |
|
|
217
217
|
| `trackingConsent` | `'granted' \| 'not-granted'` | `granted` | 初始化授权状态 |
|
|
218
218
|
| `redactUrl` | `(url) => string` | 删除 username/password/query/hash | SDK URL 属性脱敏 |
|
|
219
|
-
| `redactAttributes` | `(attributes) => Attributes` | 原样返回 | SDK
|
|
219
|
+
| `redactAttributes` | `(attributes) => Attributes` | 原样返回 | Resource、SDK 创建的 Span/Log 和内置插件属性脱敏 |
|
|
220
220
|
|
|
221
221
|
第三方 instrumentation 的自有 Span 属性不保证经过 `redactAttributes`;需要在 `tracking.beforeSend` 做最终兜底。详见[隐私与公共属性](./privacy.md)。
|
|
222
222
|
|
|
@@ -7,7 +7,7 @@ SDK 的数据模型遵循“浏览器 SDK 负责低成本原始数据和单事
|
|
|
7
7
|
## 分层模型
|
|
8
8
|
|
|
9
9
|
1. OpenTelemetry 原生字段:trace、span、resource、metric、log 的标准字段。
|
|
10
|
-
2. RUM 归一字段:`span_type`、`span_subtype`、`result`、`error_type
|
|
10
|
+
2. RUM 归一字段:`span_type`、`span_subtype`、`result`、`error_type` 等。
|
|
11
11
|
3. 运行时上下文:`user.id`、`session.id`、`view.id`、`view.url`、`view.url_path_group` 等。
|
|
12
12
|
4. 后端派生字段:session/view duration、count、地理信息、影响用户数、trace tree 分析等。
|
|
13
13
|
|
|
@@ -35,8 +35,6 @@ const span = bkOT.startSpan('custom.search', {
|
|
|
35
35
|
...buildRumSpanAttributes({
|
|
36
36
|
spanType: RUM_SPAN_TYPE.custom,
|
|
37
37
|
spanSubtype: 'search',
|
|
38
|
-
eventLabel: '业务搜索',
|
|
39
|
-
targetLabel: 'alarm',
|
|
40
38
|
}),
|
|
41
39
|
'biz.keyword_length': 6,
|
|
42
40
|
});
|
|
@@ -68,22 +66,6 @@ bkOT.reportCustomEvent({
|
|
|
68
66
|
});
|
|
69
67
|
```
|
|
70
68
|
|
|
71
|
-
## Duration Bucket
|
|
72
|
-
|
|
73
|
-
有耗时的事件会写入 `duration_bucket`:
|
|
74
|
-
|
|
75
|
-
- `<100ms`
|
|
76
|
-
- `100~500ms`
|
|
77
|
-
- `500ms~2s`
|
|
78
|
-
- `>2s`
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
import { getDurationBucket } from '@blueking/open-telemetry';
|
|
82
|
-
|
|
83
|
-
console.log(getDurationBucket(80)); // <100ms
|
|
84
|
-
console.log(getDurationBucket(1200)); // 500ms~2s
|
|
85
|
-
```
|
|
86
|
-
|
|
87
69
|
## SDK 直接采集
|
|
88
70
|
|
|
89
71
|
以下字段由浏览器 API、接入方配置或 SDK 运行期上下文直接提供:
|
|
@@ -92,7 +74,7 @@ console.log(getDurationBucket(1200)); // 500ms~2s
|
|
|
92
74
|
- 用户与会话:`user.id`、`session.id`
|
|
93
75
|
- View:`view.id`、`view.name`、`view.url`、`view.url_path_group`、`view.loading_type`
|
|
94
76
|
- 终端信息:`device.type`、`browser.name`、`browser.version`、`os.name`、`network.effective_type`
|
|
95
|
-
- HTTP / Resource:`http.request.method`、`http.response.status_code`、`url.full`、`
|
|
77
|
+
- HTTP / Resource:`http.request.method`、`http.response.status_code`、`url.full`、`resource.size`
|
|
96
78
|
- Web Vitals:`vital.metric`、`vital.value`、`vital.rating`
|
|
97
79
|
- Error Span 属性:`exception.message_short`、`exception.stack_top_frame`、`exception.fingerprint`;完整异常位于标准 `exception` Span Event
|
|
98
80
|
|
|
@@ -93,7 +93,7 @@ new BkOpenTelemetry({
|
|
|
93
93
|
|
|
94
94
|
## device
|
|
95
95
|
|
|
96
|
-
`device`
|
|
96
|
+
`device` 插件采集设备、浏览器、系统、视口和网络信息。默认开启。
|
|
97
97
|
|
|
98
98
|
```ts
|
|
99
99
|
new BkOpenTelemetry({
|
|
@@ -106,11 +106,11 @@ new BkOpenTelemetry({
|
|
|
106
106
|
});
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
稳定的浏览器、系统和硬件能力写入三类信号共享的 Resource;设备 ID、视口和网络信息保留为运行时属性,后续 span/log 会自动携带,便于按浏览器、系统、网络类型下钻。
|
|
110
110
|
|
|
111
111
|
`device.id` 默认只在当前 SDK 实例内稳定;只有显式设置 `persistentId: true` 才写入 localStorage,并按应用名隔离默认 storage key。
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
**产出遥测**:写入 Resource 属性(如 `browser.name`、`os.name`、`device.type`、`device.memory_gib`)和运行时属性(如 `device.id`、`browser.viewport.*`、`network.effective_type`),本身不单独产生 span/metric/log。
|
|
114
114
|
|
|
115
115
|
## View
|
|
116
116
|
|
|
@@ -213,7 +213,7 @@ new BkOpenTelemetry({
|
|
|
213
213
|
});
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
-
常见字段包括 `
|
|
216
|
+
常见字段包括 `resource.type`、`resource.size`、`resource.protocol`、`url.full`、`server.address`。当 Resource Timing 数据可用时,还会上报:
|
|
217
217
|
|
|
218
218
|
- `resource.redirect.*`、`resource.dns.*`、`resource.connect.*`、`resource.ssl.*`
|
|
219
219
|
- `resource.first_byte.*`、`resource.download.*`、`resource.worker.*`
|
|
@@ -426,7 +426,7 @@ new BkOpenTelemetry({
|
|
|
426
426
|
6. 等待最多 200ms 匹配 Resource Timing,把网络阶段补回同一 Span。
|
|
427
427
|
7. 如已配置 Body 且 Log 开启,异步生成关联原 `trace.id` / `span.id` 的诊断 Log。
|
|
428
428
|
|
|
429
|
-
**产出遥测**:Span `browser.resource`,`span_type=resource`、`resource.type=fetch|xhr`,常用属性包括 `
|
|
429
|
+
**产出遥测**:Span `browser.resource`,`span_type=resource`、`resource.type=fetch|xhr`,常用属性包括 `http.request.method`、`http.response.status_code`、`url.full`、`server.address`、网络阶段与响应体积。
|
|
430
430
|
|
|
431
431
|
```ts
|
|
432
432
|
new BkOpenTelemetry({
|
|
@@ -24,7 +24,7 @@ new BkOpenTelemetry({
|
|
|
24
24
|
|
|
25
25
|
## 属性脱敏
|
|
26
26
|
|
|
27
|
-
`privacy.redactAttributes`
|
|
27
|
+
`privacy.redactAttributes` 会处理 Resource、通过 SDK `startSpan()`、`emitLog()` 以及内置插件显式应用的属性,适合删除 authorization、手机号、邮箱等字段。Resource 在 SDK 构造时处理一次,后续不会动态更新。
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
30
|
new BkOpenTelemetry({
|
|
@@ -9,49 +9,52 @@
|
|
|
9
9
|
## 命名规则
|
|
10
10
|
|
|
11
11
|
- **信号名**:`browser.*` 表示内置浏览器事件(如 `browser.web_vital`);`action.<type>`、`custom.<name>` 是运行期动态拼接;`csp.violation`、`websocket.*` 使用领域前缀。
|
|
12
|
-
- **属性 key
|
|
12
|
+
- **属性 key**:标准字段与 RUM 领域字段均使用点号命名空间(如 `http.request.method`、`exception.type`、`view.id`、`session.id`、`browser.name`);跨类型检索字段使用下划线(如 `span_type`、`span_subtype`、`result`)。字段常量集中定义在 `src/schema/attributes.ts`。
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## 公共 Resource 与运行时上下文属性
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Resource 属性由三类信号共享;运行时上下文属性自动挂到**几乎所有** span / log 上(metric 视插件而定)。后续各清单不再重复列出:
|
|
17
17
|
|
|
18
|
-
| key | 类型 | 说明 | 低基数 |
|
|
19
|
-
| --- | --- | --- | --- |
|
|
20
|
-
| `service.name` | string | 应用名(`application.name`) | 是 |
|
|
21
|
-
| `service.version` | string | 应用版本(`application.version`,可选) | 是 |
|
|
22
|
-
| `deployment.environment.name` | string | 环境(`application.environment`) | 是 |
|
|
23
|
-
| `rum.
|
|
24
|
-
| `telemetry.sdk.language` | string |
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
| key | 归属 | 类型 | 说明 | 低基数 |
|
|
19
|
+
| --- | --- | --- | --- | --- |
|
|
20
|
+
| `service.name` | Resource | string | 应用名(`application.name`) | 是 |
|
|
21
|
+
| `service.version` | Resource | string | 应用版本(`application.version`,可选) | 是 |
|
|
22
|
+
| `deployment.environment.name` | Resource | string | 环境(`application.environment`) | 是 |
|
|
23
|
+
| `rum.schema.version` | Resource | string | 当前固定 `2` | 是 |
|
|
24
|
+
| `telemetry.sdk.name` / `telemetry.sdk.language` / `telemetry.sdk.version` | Resource | string | SDK 名、语言和包版本 | 是 |
|
|
25
|
+
| `device.type` | Resource | string | `mobile` / `desktop` | 是 |
|
|
26
|
+
| `browser.name` / `browser.version` | Resource | string | 归一化浏览器信息 | 是 |
|
|
27
|
+
| `os.name` | Resource | string | 操作系统 | 是 |
|
|
28
|
+
| `device.memory_gib` | Resource | number | 浏览器暴露的近似设备内存(GiB) | 是 |
|
|
29
|
+
| `device.logical_processor_count` | Resource | number | 浏览器暴露的逻辑处理器数量 | 是 |
|
|
30
|
+
| `user.id` | Runtime | string | 接入方提供,原样透传 | 否 |
|
|
31
|
+
| `session.id` | Runtime | string | session 插件生成/轮换 | 否 |
|
|
32
|
+
| `session.has_replay` | Runtime | boolean | 当前固定 `false` | 是 |
|
|
33
|
+
| `view.id` | Runtime | string | View 管理器生成的实例 ID | 否 |
|
|
34
|
+
| `view.name` | Runtime | string | 自动模式默认使用路由分组;手动模式可指定 | 是 |
|
|
35
|
+
| `view.url` | Runtime | string | 当前 view URL(已脱敏) | 否 |
|
|
36
|
+
| `view.url_path_group` | Runtime | string | 低基数路由模板 | 是 |
|
|
37
|
+
| `view.loading_type` | Runtime | string | `initial_load` / `route_change` / `session_renewal` / `bf_cache` | 是 |
|
|
38
|
+
| `device.id` | Runtime | string | 当前实例或持久化匿名设备 ID | 否 |
|
|
39
|
+
| `network.effective_type` | Runtime | string | 网络质量(`4g` 等) | 是 |
|
|
40
|
+
|
|
41
|
+
> span 还会带上 `span_type` / `span_subtype` / `result` / `error_type` 等归一字段(见下方[归一字段](#归一字段))。接入方可通过 `context.attributes.page` 注入额外的页面属性。
|
|
39
42
|
|
|
40
43
|
## Span 清单
|
|
41
44
|
|
|
42
45
|
| span 名 | span_type | 来源 | 关键属性 | 备注 |
|
|
43
46
|
| --- | --- | --- | --- | --- |
|
|
44
47
|
| `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`、`
|
|
46
|
-
| `browser.resource` | `resource` | resource 插件 | `resource.type`、`
|
|
48
|
+
| `browser.resource` | `resource` | Fetch/XHR request 采集 | `resource.type=fetch\|xhr`、`url.full`、`http.request.method`、`http.response.status_code`、网络阶段属性 | span kind 为 CLIENT;Fetch/XHR 共用同一实现 |
|
|
49
|
+
| `browser.resource` | `resource` | resource 插件 | `resource.type`、`url.full`、`resource.size`、网络阶段、`resource.render_blocking_status`、`resource.protocol`、`resource.cache.hit` | 仅静态资源,跳过 Fetch/XHR |
|
|
47
50
|
| `browser.web_vital` | `vital` | webVitals 插件 | `vital.metric`、`vital.value`、`vital.rating`、`vital.id`、`rum.navigation.type`、`vital.<lcp\|cls\|inp\|fcp\|ttfb>.*` | 每个指标一条 |
|
|
48
51
|
| `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 最多一条 |
|
|
49
52
|
| `browser.error` | `error` | error 插件(`window.error`) | `exception.fingerprint`、`exception.message_short`、`exception.stack_top_frame`、`error.source=window.error`、`error.window_occurrence_index`、`code.filepath`、`code.lineno`、`code.column`、`error.cross_origin` | 完整异常写入标准 `exception` Span Event |
|
|
50
53
|
| `browser.unhandledrejection` | `error` | error 插件(Promise 异常) | `exception.fingerprint`、`error.source=unhandledrejection` | 完整异常写入标准 `exception` Span Event |
|
|
51
54
|
| `browser.resource_error` | `error` | error 插件(资源加载失败) | `exception.fingerprint`、`error.source=resource`、`url.full`、`html.tag` | 完整异常写入标准 `exception` Span Event |
|
|
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
|
|
55
|
+
| `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` | LoAF 脚本详情写入 `long_task.script` Span Event |
|
|
53
56
|
| `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_occurrence_index`、`csp.original_policy`(窗口首条) | |
|
|
54
|
-
| `websocket.connect` | `custom` | websocket 插件(仅建连阶段) | `url.full`、`url.scheme`、`server.address`、`network.protocol.name=websocket
|
|
57
|
+
| `websocket.connect` | `custom` | websocket 插件(仅建连阶段) | `url.full`、`url.scheme`、`server.address`、`network.protocol.name=websocket` | 长连接生命周期不绑定 span |
|
|
55
58
|
| `action.click` / `action.custom` | `action` | action 插件 / `reportAction()` | `action.id/name/type/target.*`、`action.loading_time`、`action.frustration.*`、`action.*.count` | 自动点击或手动动作;挫败信号仅自动点击 |
|
|
56
59
|
| `custom.<name>` | `custom` | `reportCustomEvent()` / 自定义插件 | `rum.custom.name`、业务自定义属性 | 带 `error` 时记录 exception、设置错误 Status/Result,`span_type` 仍为 `custom` |
|
|
57
60
|
|
|
@@ -100,14 +103,6 @@
|
|
|
100
103
|
| `span_subtype` | string | 子类型,如 `fetch`/`xhr`/`js`/`promise`/`lcp` | 是 |
|
|
101
104
|
| `result` | string | `success`/`warning`/`error`/`timeout`/`abort` | 是 |
|
|
102
105
|
| `error_type` | string | 错误细分,如 `http_5xx`/`network_timeout`/`slow`/`none` | 是 |
|
|
103
|
-
| `duration_bucket` | string | `<100ms`/`100~500ms`/`500ms~2s`/`>2s` | 是 |
|
|
104
|
-
| `event_label` | string | 中文事件标签,如 `API 调用`/`错误` | 是 |
|
|
105
|
-
| `target_label` | string | 跨类型主标签,用于统一检索 | 中 |
|
|
106
|
-
| `target_value` | number/string/bool | 主数值(状态码、耗时、字节数等) | 否 |
|
|
107
|
-
| `target_domain` | string | 目标域名 | 中 |
|
|
108
|
-
| `target_path_template` | string | 目标低基数路径模板 | 是 |
|
|
109
|
-
| `status_class` | string | HTTP 状态段,如 `2xx`/`5xx` | 是 |
|
|
110
|
-
| `trace_scene` | string | `page_load` / `route_change` | 是 |
|
|
111
106
|
|
|
112
107
|
### HTTP / Resource
|
|
113
108
|
|
|
@@ -116,11 +111,9 @@
|
|
|
116
111
|
| `http.request.method` | string | 请求方法(大写) |
|
|
117
112
|
| `http.response.status_code` | number | 响应状态码 |
|
|
118
113
|
| `url.full` | string | 完整 URL(已脱敏) |
|
|
114
|
+
| `server.address` | string | 目标主机名 |
|
|
115
|
+
| `server.port` | number | 目标显式端口(存在时) |
|
|
119
116
|
| `resource.type` | string | `fetch`/`xhr` 或静态资源 initiator type |
|
|
120
|
-
| `resource.url` | string | 资源 URL(已脱敏) |
|
|
121
|
-
| `resource.method` | string | 请求方法(Fetch/XHR) |
|
|
122
|
-
| `resource.status_code` | number | 请求状态码(Fetch/XHR) |
|
|
123
|
-
| `resource.duration` | number | 静态资源耗时(ms);请求耗时使用 Span 原生 duration |
|
|
124
117
|
| `resource.redirect.start/duration` | number | 重定向阶段相对开始时间 / 耗时(ms) |
|
|
125
118
|
| `resource.dns.start/duration` | number | DNS 阶段相对开始时间 / 耗时(ms) |
|
|
126
119
|
| `resource.connect.start/duration` | number | TCP 建连阶段相对开始时间 / 耗时(ms) |
|
|
@@ -132,10 +125,8 @@
|
|
|
132
125
|
| `resource.render_blocking_status` | string | `blocking` / `non-blocking` |
|
|
133
126
|
| `resource.size` | number | 传输字节数 |
|
|
134
127
|
| `url.previous` | string | 跳转前 URL |
|
|
135
|
-
| `transfer_size` | number | 传输字节数 |
|
|
136
128
|
| `resource.cache.hit` | boolean | 是否命中缓存 |
|
|
137
129
|
| `resource.protocol` | string | 协议,如 `h2` |
|
|
138
|
-
| `initiator_type` | string | 资源发起类型 |
|
|
139
130
|
| `resource.encoded_body_size` / `resource.decoded_body_size` | number | 资源体积 |
|
|
140
131
|
| `request.body` / `response.body` | string | 仅 `browser.request.body` Log;经过接入方 `redact` 且受长度限制 |
|
|
141
132
|
| `request.body.content_type` / `response.body.content_type` | string | body Content-Type(可获取时) |
|
|
@@ -174,13 +165,13 @@
|
|
|
174
165
|
| key | 类型 | 说明 |
|
|
175
166
|
| --- | --- | --- |
|
|
176
167
|
| `device.id` | string | 匿名设备标识;默认仅当前 SDK 实例稳定,`tracking.device.persistentId=true` 时持久化 |
|
|
177
|
-
| `device.
|
|
178
|
-
| `device.
|
|
168
|
+
| `device.memory_gib` | number | Resource 中的近似设备内存(GiB) |
|
|
169
|
+
| `device.logical_processor_count` | number | Resource 中的逻辑处理器数量 |
|
|
179
170
|
| `browser.viewport.width` / `browser.viewport.height` | number | 视口尺寸 |
|
|
180
171
|
| `browser.screen.width` / `browser.screen.height` | number | 屏幕尺寸 |
|
|
181
172
|
| `network.connection_type` / `network.downlink` / `network.rtt` / `network.save_data` | mixed | 网络信息 |
|
|
182
|
-
| `browser.name` / `browser.version` / `os.name` | string | UA 解析结果 |
|
|
183
|
-
| `device.type` | string | `mobile` / `desktop` |
|
|
173
|
+
| `browser.name` / `browser.version` / `os.name` | string | Resource 中的 UA 解析结果 |
|
|
174
|
+
| `device.type` | string | Resource 中的 `mobile` / `desktop` |
|
|
184
175
|
|
|
185
176
|
### 用户动作 / 会话
|
|
186
177
|
|