@blueking/open-telemetry 0.0.6 → 0.0.7

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.
@@ -0,0 +1,3 @@
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createActionPlugin: (option: ResolvedRumPluginConfig["action"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createBlankScreenPlugin: (option: BkOTRumConfig["blankScreen"]) => BkOTPlugin;
3
+ export declare const createBlankScreenPlugin: (option: ResolvedRumPluginConfig["blankScreen"]) => BkOTPlugin;
@@ -1,4 +1,4 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
3
  /**
4
4
  * CSP 违规事件采集插件,通过监听 `securitypolicyviolation` 事件捕获被 CSP 策略拦截的脚本/资源,
@@ -16,4 +16,4 @@ import type { BkOTPlugin } from '../core/plugin';
16
16
  * - `blockedURI` / `sourceFile` 中的 URL 类值会经 `redactUrl` 脱敏。
17
17
  * - `blockedURI` 是 'inline' / 'eval' 等 CSP 关键字时直接保留,不调用 redactUrl。
18
18
  */
19
- export declare const createCspViolationPlugin: (option: BkOTRumConfig["cspViolation"]) => BkOTPlugin;
19
+ export declare const createCspViolationPlugin: (option: ResolvedRumPluginConfig["cspViolation"]) => BkOTPlugin;
@@ -1,4 +1,4 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
3
  /**
4
4
  * 设备元数据采集插件,把"设备级"信息写入 SDK 的 runtimeAttributes,
@@ -20,4 +20,4 @@ import type { BkOTPlugin } from '../core/plugin';
20
20
  *
21
21
  * 与 session 插件的关系:device 跨会话持久(终身),session 有过期与续期(连续访问语义)。
22
22
  */
23
- export declare const createDevicePlugin: (option: BkOTRumConfig["device"]) => BkOTPlugin;
23
+ export declare const createDevicePlugin: (option: ResolvedRumPluginConfig["device"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createErrorPlugin: (option: BkOTRumConfig["error"]) => BkOTPlugin;
3
+ export declare const createErrorPlugin: (option: ResolvedRumPluginConfig["error"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
- import type { BkOTHttpBodyConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createHttpBodyPlugin: (option: false | Required<BkOTHttpBodyConfig>) => BkOTPlugin;
3
+ export declare const createHttpBodyPlugin: (option: ResolvedRumPluginConfig["httpBody"]) => BkOTPlugin;
@@ -1,4 +1,4 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
3
  /**
4
4
  * Long Task 监控插件,通过 PerformanceObserver 捕获主线程上 >= threshold(默认 50ms)的长任务,
@@ -12,4 +12,4 @@ import type { BkOTPlugin } from '../core/plugin';
12
12
  * - 仅在 PerformanceObserver 与 `supportedEntryTypes` 包含 `longtask` 的浏览器上启用,否则 init 直接 return;
13
13
  * Firefox 当前不支持 longtask,会自动跳过。
14
14
  */
15
- export declare const createLongTaskPlugin: (option: BkOTRumConfig["longTask"]) => BkOTPlugin;
15
+ export declare const createLongTaskPlugin: (option: ResolvedRumPluginConfig["longTask"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createPageViewPlugin: (option: BkOTRumConfig["pageView"]) => BkOTPlugin;
3
+ export declare const createPageViewPlugin: (option: ResolvedRumPluginConfig["pageView"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createResourcePlugin: (option: ResolvedRumPluginConfig["resource"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createRouteTimingPlugin: (option: BkOTRumConfig["routeTiming"]) => BkOTPlugin;
3
+ export declare const createRouteTimingPlugin: (option: ResolvedRumPluginConfig["routeTiming"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createSessionPlugin: (option: BkOTRumConfig["session"]) => BkOTPlugin;
3
+ export declare const createSessionPlugin: (option: ResolvedRumPluginConfig["session"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createWebVitalsPlugin: (option: BkOTRumConfig["webVitals"]) => BkOTPlugin;
3
+ export declare const createWebVitalsPlugin: (option: ResolvedRumPluginConfig["webVitals"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
- import type { BkOTRumConfig } from '../core/config';
1
+ import type { ResolvedRumPluginConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createWebSocketPlugin: (option: BkOTRumConfig["websocket"]) => BkOTPlugin;
3
+ export declare const createWebSocketPlugin: (option: ResolvedRumPluginConfig["websocket"]) => BkOTPlugin;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * RUM 上报字段 key 集中定义。
3
+ *
4
+ * 插件里不要散落硬编码字符串,后续字段命名调整只改这里,避免采集端与字段文档逐步漂移。
5
+ */
6
+ export declare const RUM_ATTRIBUTES: {
7
+ readonly actionType: "action.type";
8
+ readonly deploymentEnvironmentName: "deployment.environment.name";
9
+ readonly browserName: "browser_name";
10
+ readonly browserVersion: "browser_version";
11
+ readonly cacheHit: "cache_hit";
12
+ readonly deviceType: "device_type";
13
+ readonly durationBucket: "duration_bucket";
14
+ readonly errorType: "error_type";
15
+ readonly eventLabel: "event_label";
16
+ readonly exceptionFingerprint: "exception.fingerprint";
17
+ readonly exceptionMessageShort: "exception.message_short";
18
+ readonly exceptionStackTopFrame: "exception.stack_top_frame";
19
+ readonly longtaskAttributionScript: "longtask.attribution_script";
20
+ readonly longtaskBlockingDuration: "longtask.blocking_duration";
21
+ readonly networkEffectiveType: "network.effective_type";
22
+ readonly nextHopProtocol: "next_hop_protocol";
23
+ readonly result: "result";
24
+ readonly serviceName: "service.name";
25
+ readonly serviceVersion: "service.version";
26
+ readonly osName: "os_name";
27
+ readonly sessionHasReplay: "session.has_replay";
28
+ readonly sessionId: "session.id";
29
+ readonly sessionStartTime: "session.start_time";
30
+ readonly spanSubtype: "span_subtype";
31
+ readonly spanType: "span_type";
32
+ readonly statusClass: "status_class";
33
+ readonly targetDomain: "target_domain";
34
+ readonly targetLabel: "target_label";
35
+ readonly targetPathTemplate: "target_path_template";
36
+ readonly targetTag: "target.tag";
37
+ readonly targetTextShort: "target.text_short";
38
+ readonly targetValue: "target_value";
39
+ readonly traceScene: "trace_scene";
40
+ readonly transferSize: "transfer_size";
41
+ readonly userId: "user.id";
42
+ readonly vitalMetric: "vital.metric";
43
+ readonly vitalRating: "vital.rating";
44
+ readonly vitalValue: "vital.value";
45
+ readonly viewId: "view.id";
46
+ readonly viewLoadingType: "view.loading_type";
47
+ readonly viewUrl: "view.url";
48
+ readonly viewUrlPathGroup: "view.url_path_group";
49
+ };
50
+ export type RumAttributeKey = (typeof RUM_ATTRIBUTES)[keyof typeof RUM_ATTRIBUTES];
@@ -0,0 +1,62 @@
1
+ import type { Attributes } from '@opentelemetry/api';
2
+ export declare const RUM_SPAN_RESULT: {
3
+ readonly abort: "abort";
4
+ readonly error: "error";
5
+ readonly success: "success";
6
+ readonly timeout: "timeout";
7
+ readonly warning: "warning";
8
+ };
9
+ export declare const RUM_SPAN_TYPE: {
10
+ readonly action: "action";
11
+ readonly custom: "custom";
12
+ readonly document: "document";
13
+ readonly error: "error";
14
+ readonly http: "http";
15
+ readonly longtask: "longtask";
16
+ readonly resource: "resource";
17
+ readonly route: "route";
18
+ readonly vital: "vital";
19
+ };
20
+ export interface RumHttpSpanInput {
21
+ duration?: number;
22
+ method?: string;
23
+ statusCode?: number;
24
+ subtype: 'fetch' | 'xhr';
25
+ url?: string;
26
+ urlPathTemplate?: string;
27
+ }
28
+ export interface RumResourceSpanInput {
29
+ duration: number;
30
+ initiatorType?: string;
31
+ responseStatus?: number;
32
+ transferSize?: number;
33
+ url: string;
34
+ urlPathTemplate?: string;
35
+ }
36
+ export interface RumSpanClassification {
37
+ duration?: number;
38
+ errorType?: string;
39
+ eventLabel?: string;
40
+ result?: RumSpanResult;
41
+ spanSubtype: string;
42
+ spanType: RumSpanType;
43
+ targetLabel?: string;
44
+ targetValue?: boolean | number | string;
45
+ traceScene?: string;
46
+ }
47
+ export type RumSpanResult = (typeof RUM_SPAN_RESULT)[keyof typeof RUM_SPAN_RESULT];
48
+ export type RumSpanType = (typeof RUM_SPAN_TYPE)[keyof typeof RUM_SPAN_TYPE];
49
+ export interface RumUrlTarget {
50
+ domain?: string;
51
+ label?: string;
52
+ pathTemplate?: string;
53
+ }
54
+ export declare const getDurationBucket: (duration: number) => "<100ms" | "100~500ms" | "500ms~2s" | ">2s";
55
+ export declare const getStatusClass: (statusCode: number) => string;
56
+ export declare const getHttpResult: (statusCode: number | undefined) => RumSpanResult;
57
+ export declare const getHttpErrorType: (statusCode: number | undefined) => "none" | "network_timeout" | "http_5xx" | "http_4xx";
58
+ export declare const getVitalResult: (rating: string | undefined) => RumSpanResult;
59
+ export declare const getUrlTarget: (url: string | undefined, pathTemplate?: string) => RumUrlTarget;
60
+ export declare const buildRumSpanAttributes: ({ duration, errorType, eventLabel, result, spanSubtype, spanType, targetLabel, targetValue, traceScene, }: RumSpanClassification) => Attributes;
61
+ export declare const buildRumHttpSpanAttributes: ({ duration, method, statusCode, subtype, url, urlPathTemplate, }: RumHttpSpanInput) => Attributes;
62
+ export declare const buildRumResourceSpanAttributes: ({ duration, initiatorType, responseStatus, transferSize, url, urlPathTemplate, }: RumResourceSpanInput) => Attributes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/open-telemetry",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "OpenTelemetry browser SDK for BK RUM",
5
5
  "author": "TencentCloud Real User Monitoring",
6
6
  "main": "dist/index.js",
@@ -12,9 +12,12 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "prepublishOnly": "pnpm build && pnpm dts",
15
- "build": "vite build && vite build --mode cdn",
15
+ "build": "vite build && vite build --mode cdn && pnpm dts",
16
16
  "build:cdn": "vite build --mode cdn",
17
17
  "build:esm": "vite build",
18
+ "docs:build": "vitepress build wikis",
19
+ "docs:dev": "vitepress dev wikis",
20
+ "docs:preview": "vitepress preview wikis",
18
21
  "dev": "vite dev",
19
22
  "dts": "vue-tsc --project tsconfig.dts.json"
20
23
  },
@@ -46,6 +49,7 @@
46
49
  "@vue/tsconfig": "^0.9.0",
47
50
  "vite": "^8.0.2",
48
51
  "vite-bundle-analyzer": "^1.3.2",
52
+ "vitepress": "2.0.0-alpha.16",
49
53
  "vue": "^3.5.34",
50
54
  "vue-router": "^5.0.6",
51
55
  "vue-tsc": "^3.1.4"