@blueking/open-telemetry 0.0.29 → 0.0.31

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.
@@ -16,11 +16,9 @@ export interface BkOTBlankScreenPluginOptions {
16
16
  threshold?: number;
17
17
  }
18
18
  interface DetectionResult {
19
- centerElement: string;
20
19
  emptyCount: number;
21
20
  ignoredCount: number;
22
21
  reason: 'empty_viewport' | 'missing_root';
23
- rootFound: boolean;
24
22
  score: number;
25
23
  validCount: number;
26
24
  }
@@ -11,7 +11,6 @@ export declare const getDeviceResourceAttributes: () => Attributes;
11
11
  *
12
12
  * 上报字段:
13
13
  * - `device.id`:设备级永久标识,存于 localStorage(默认 key 复用旧 session 插件以保留现网用户)。
14
- * - `device.memory_gib`:硬件能力快照,写入 Resource。
15
14
  * - `user_agent.name` / `user_agent.version` / `user_agent.os.name`:User Agent 信息,写入 Resource。
16
15
  * - `browser.viewport.*` / `browser.screen.*`:视口与屏幕尺寸。
17
16
  * - `network.status` / `network.effective_type` / `network.connection.type`:网络信息。
@@ -38,16 +38,11 @@ interface InpCandidate {
38
38
  }
39
39
  interface LayoutShiftEntry extends PerformanceEntry {
40
40
  hadRecentInput?: boolean;
41
- sources?: Array<{
42
- node?: Node | null;
43
- }>;
44
41
  value?: number;
45
42
  }
46
43
  interface ViewVitalState {
47
44
  cls: number;
48
45
  clsWindowEnd?: number;
49
- clsWindowLargestShiftTarget?: string;
50
- clsWindowLargestShiftValue: number;
51
46
  clsWindowStart?: number;
52
47
  clsWindowValue: number;
53
48
  id: string;
@@ -55,8 +50,6 @@ interface ViewVitalState {
55
50
  interactionCountAtStart?: number;
56
51
  interactionIdMax: number;
57
52
  interactionIdMin: number;
58
- largestShiftTarget?: string;
59
- largestShiftValue: number;
60
53
  runtimeAttributes: Attributes;
61
54
  startedAt: number;
62
55
  }
@@ -6,24 +6,18 @@
6
6
  export declare const RUM_ATTRIBUTES: {
7
7
  readonly actionFrustrationType: "action.frustration.type";
8
8
  readonly actionId: "action.id";
9
- readonly actionLoadingTime: "action.loading_time";
10
- readonly actionName: "action.name";
11
9
  readonly actionTargetName: "action.target.name";
12
10
  readonly actionTargetTag: "action.target.tag";
13
11
  readonly actionType: "action.type";
14
12
  readonly deploymentEnvironmentName: "deployment.environment.name";
15
13
  readonly cacheHit: "resource.cache.hit";
16
- readonly deviceMemoryGib: "device.memory_gib";
17
14
  readonly deviceType: "device.type";
18
15
  readonly longTaskBlockingDuration: "long_task.blocking_duration";
19
- readonly longTaskDuration: "long_task.duration";
20
16
  readonly longTaskEntryType: "long_task.entry_type";
21
17
  readonly longTaskId: "long_task.id";
22
- readonly longTaskStartTime: "long_task.start_time";
23
18
  readonly networkEffectiveType: "network.effective_type";
24
19
  readonly networkStatus: "network.status";
25
20
  readonly nextHopProtocol: "resource.protocol";
26
- readonly outcomeReason: "outcome.reason";
27
21
  readonly outcomeType: "outcome.type";
28
22
  readonly serviceName: "service.name";
29
23
  readonly serviceVersion: "service.version";
@@ -31,7 +25,6 @@ export declare const RUM_ATTRIBUTES: {
31
25
  readonly sessionId: "session.id";
32
26
  readonly sessionSampleRate: "session.sample_rate";
33
27
  readonly sessionPhase: "session.phase";
34
- readonly sessionStartTime: "session.start_time";
35
28
  readonly sessionType: "session.type";
36
29
  readonly spanType: "span_type";
37
30
  readonly userId: "user.id";
@@ -39,7 +32,6 @@ export declare const RUM_ATTRIBUTES: {
39
32
  readonly userAgentOsName: "user_agent.os.name";
40
33
  readonly userAgentVersion: "user_agent.version";
41
34
  readonly vitalMetric: "vital.metric";
42
- readonly vitalRating: "vital.rating";
43
35
  readonly vitalValue: "vital.value";
44
36
  readonly viewDomComplete: "view.dom_complete";
45
37
  readonly viewDomContentLoaded: "view.dom_content_loaded";
@@ -52,6 +44,9 @@ export declare const RUM_ATTRIBUTES: {
52
44
  readonly viewLoadingType: "view.loading_type";
53
45
  readonly viewName: "view.name";
54
46
  readonly viewPhase: "view.phase";
47
+ readonly viewPrevious: "view.previous";
48
+ readonly viewPreviousUrlTemplate: "view.previous_url_template";
49
+ readonly viewReferrer: "view.referrer";
55
50
  readonly viewStartedAt: "view.started_at";
56
51
  readonly viewUrl: "view.url";
57
52
  readonly viewUrlTemplate: "view.url_template";
@@ -37,7 +37,6 @@ export interface RumResourceSpanInput {
37
37
  }
38
38
  export interface RumSpanClassification {
39
39
  outcome?: RumSpanOutcome;
40
- outcomeReason?: string;
41
40
  spanType: RumSpanType;
42
41
  }
43
42
  export type RumSpanOutcome = (typeof RUM_SPAN_OUTCOME)[keyof typeof RUM_SPAN_OUTCOME];
@@ -47,8 +46,7 @@ export interface RumUrlTarget {
47
46
  serverPort?: number;
48
47
  }
49
48
  export declare const getHttpOutcome: (statusCode: number | undefined) => RumSpanOutcome;
50
- export declare const getHttpOutcomeReason: (statusCode: number | undefined) => "network_timeout" | "http_5xx" | "http_4xx" | undefined;
51
49
  export declare const getVitalOutcome: (rating: string | undefined) => RumSpanOutcome;
52
50
  export declare const getUrlTarget: (url: string | undefined) => RumUrlTarget;
53
- export declare const buildRumSpanAttributes: ({ outcome, outcomeReason, spanType, }: RumSpanClassification) => Attributes;
51
+ export declare const buildRumSpanAttributes: ({ outcome, spanType, }: RumSpanClassification) => Attributes;
54
52
  export declare const buildRumResourceSpanAttributes: ({ initiatorType, method, outcome, url, }: RumResourceSpanInput) => Attributes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/open-telemetry",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "OpenTelemetry browser SDK for BK RUM",
5
5
  "author": "TencentCloud Real User Monitoring",
6
6
  "main": "dist/index.js",
@@ -39,7 +39,8 @@ description: 帮助业务方在前端应用里接入、使用和配置蓝鲸 RUM
39
39
  | Vue / React / Router / SSR / 微前端集成 | `references/framework-integration.md` |
40
40
  | URL/属性脱敏、Consent、低基数路由、user.id 和服务端隐私责任 | `references/privacy.md` |
41
41
  | 查 Transport、OTLP JSON、批量队列、重试、keepalive、Session 采样和 CORS | `references/transport-sampling.md` |
42
- | 查具体 Span 名、OTLP Envelope、Resource/Span/Event 完整字段字典 | `references/telemetry-reference.md` |
42
+ | 查前后端 RUM 语义约定、字段状态和协议映射 | `references/span-protocol.md` |
43
+ | 查当前 SDK 实际发出的 Span、OTLP Envelope、Resource/Span/Event 完整字段字典 | `references/telemetry-reference.md` |
43
44
  | 没有数据、手动事件没上报、白屏误报、接口 Span 太多、字段缺失等排障 | `references/troubleshooting.md` |
44
45
 
45
46
  > `references/` 由 `packages/open-telemetry/scripts/gen-skill-references.mjs` 从 SDK 的 `wikis/` 自动生成,请勿手改。如内容过期,让维护者重新执行 `pnpm --filter @blueking/open-telemetry skill:refs`。
@@ -10,7 +10,7 @@ Action 表示一次用户操作以及操作后引发的页面活动。SDK 默认
10
10
 
11
11
  1. 从 Event 取得真实发生时间和 composed target。
12
12
  2. 生成 `action.id`,保存当时的 Session/View 上下文。
13
- 3. 把活动中的 Action ID 写入运行时上下文,后续请求、资源、错误和 Long Task 自动关联。
13
+ 3. 把当前活动的 `action.id` 字符串写入运行时上下文,后续请求、资源、错误和 Long Task 自动关联。多个点击窗口重叠时取最近一次。
14
14
  4. 观察请求、DOM Mutation、Resource、Long Task、Error 和部分用户行为。
15
15
  5. 发生过页面活动后,等待所有请求完成并连续 100ms 无活动。
16
16
  6. 最长等待 `maxDuration`,默认 10 秒。
@@ -69,7 +69,9 @@ User(业务提供,可变)
69
69
  - `user.id`:业务方传入,可在 Session 内变化。
70
70
  - `session.id`:Session 插件生成,是采样和访问会话边界。
71
71
  - `view.id`:每个 View 新生成,是普通 RUM Span 的必要关联字段。
72
- - `action.id`:自动 Action 活动窗口内为数组,Action 自身 Span 上为当前 Action ID;手动 Action 生成独立 ID。
72
+ - `action.id`:始终是字符串。
73
+ 自动 Action 活动窗口内写入当前活动 Action ID,多个点击窗口重叠时取最近一次。
74
+ Action 自身 Span 和手动 Action 各自写入当前 Action ID。
73
75
 
74
76
  普通 Span 没有有效 Session 和 View 时不会导出。Session 生命周期 Span允许没有 View。
75
77
 
@@ -43,7 +43,9 @@ Fetch 和 XHR 都生成 `browser.resource`:
43
43
  | `http.response.status_code` | 获得真实 Response status 时 | `load` 且 `xhr.status>0` 时 |
44
44
  | Span Kind | CLIENT | CLIENT |
45
45
 
46
- `url.template` 是给后端按 API 路由聚合用的低基数维度(semconv `url.template`,当前仍是 Development 阶段)。默认取 pathname 并把数字 ID、UUID、长十六进制段折叠为 `:id`,`/api/orders/1001` 与 `/api/orders/1002` 都归到 `/api/orders/:id`。两点已知代价:纯数字段无法与语义段区分,`/reports/2024/summary` 会变成 `/reports/:id/summary`;模板按 semconv 定义不含 host,跨域同路径会聚到一起,需要区分来源时配合 `server.address`。需要精确模板时用 `tracking.request.getUrlTemplate` 覆盖,它拿到的是未脱敏 URL(便于按 query 判断路由),返回空值或抛错都回退到默认规则。
46
+ `url.template` 是给后端按路径聚合用的低基数维度(semconv `url.template`,当前仍是 Development 阶段)。Fetch/XHR 和静态资源 Span 都取 pathname,并把数字 ID、UUID、长十六进制段折叠为 `:id`。例如,`/api/orders/1001` 与 `/api/orders/1002` 都归到 `/api/orders/:id`。
47
+
48
+ 需要精确模板时用 `tracking.request.getUrlTemplate` 覆盖。Fetch/XHR 会传入未脱敏 URL,便于按 query 判断路由;静态资源先通过 `redactUrl` 脱敏,再把结果传给该 Hook。返回空值或抛错都回退到默认规则。两点已知代价:纯数字段无法与语义段区分,`/reports/2024/summary` 会变成 `/reports/:id/summary`;模板按 semconv 定义不含 host,跨域同路径会聚到一起,需要区分来源时配合 `server.address`。
47
49
 
48
50
  这套折叠规则与 View 的 `view.url_template` 共用,但入口独立:页面路由和 API 路径的模板规则通常不同,所以 `tracking.view.getUrlTemplate` 与 `tracking.request.getUrlTemplate` 互不影响。
49
51
 
@@ -226,6 +228,8 @@ Fetch resolve/reject 和 XHR 终止事件往往早于 Resource Timing Observer
226
228
 
227
229
  | 字段 | 说明 |
228
230
  | --------------------------------- | ---------------------------------------------------------- |
231
+ | `url.full` | 绝对 URL,经 `redactUrl` 脱敏 |
232
+ | `url.template` | 脱敏后的低基数 pathname;默认折叠数字 ID、UUID 和长十六进制段 |
229
233
  | `resource.type` | initiator type |
230
234
  | `resource.size` | `decodedBodySize`(解压后 Body Size) |
231
235
  | `resource.encoded_body_size` | 编码后 Body Size |
@@ -306,4 +310,4 @@ Span 名统一为 `browser.websocket`,通过 `websocket.phase` 区分,不使
306
310
 
307
311
  检查 URL 是否真正命中 `allowedTracingUrls`、浏览器预检是否成功、服务端是否允许 `traceparent`,以及代理是否删除该 Header。
308
312
 
309
- 完整字段见[遥测字段字典](./telemetry-reference.md#请求与静态资源字段)。
313
+ 完整字段见[遥测字段字典](./telemetry-reference.md#请求与静态资源字段)。产品阶段图见[RUM 语义约定 · 资源加载时序](./span-protocol.md#0x04-资源加载时序)。
@@ -102,7 +102,7 @@ tracking: {
102
102
  - `redactUrl`:隐私和敏感数据边界;
103
103
  - `getUrlTemplate`:聚合维度和查询基数。
104
104
 
105
- 请求侧的 `tracking.request.getUrlTemplate` 同理,只生成 `url.template`,不影响 `url.full` 的脱敏。注意它收到的是**未脱敏**的请求 URL,因此自定义实现不要把 query 里的原值拼进返回的模板。
105
+ 请求侧的 `tracking.request.getUrlTemplate` 同理,只生成 `url.template`,不影响 `url.full` 的脱敏。Fetch/XHR 会传入**未脱敏**的请求 URL,因此自定义实现不要把 query 里的原值拼进返回的模板。静态资源先通过 `redactUrl` 脱敏,再把结果传给该 Hook,避免模板重新暴露已从 `url.full` 移除的路径信息。
106
106
 
107
107
  未配置 `context.attributes.page` 时默认返回空对象,不存在独立的默认页面属性路径。页面地址统一由经过 `redactUrl` 的 `view.url` 表达,聚合维度使用 `view.url_template`;业务通过该 Hook 添加的属性仍需自行确保不包含敏感信息。
108
108