@blueking/open-telemetry 0.0.22 → 0.0.24

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.
Files changed (44) hide show
  1. package/README.md +256 -70
  2. package/dist/bk-rum.global.js +2 -2
  3. package/dist/bk-rum.global.js.map +1 -1
  4. package/dist/core/config.d.ts +4 -2
  5. package/dist/core/processor.d.ts +2 -2
  6. package/dist/core/runtime-context.d.ts +4 -0
  7. package/dist/core/sampling.d.ts +0 -1
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.js +395 -477
  10. package/dist/index.js.map +1 -1
  11. package/dist/plugins/blank-screen.d.ts +1 -1
  12. package/dist/plugins/common.d.ts +3 -4
  13. package/dist/plugins/web-vitals.d.ts +0 -5
  14. package/dist/schema/attributes.d.ts +6 -8
  15. package/dist/schema/span.d.ts +24 -15
  16. package/package.json +1 -1
  17. package/skills/bk-rum-otele/SKILL.md +26 -23
  18. package/skills/bk-rum-otele/references/actions.md +166 -0
  19. package/skills/bk-rum-otele/references/api.md +248 -215
  20. package/skills/bk-rum-otele/references/architecture.md +139 -37
  21. package/skills/bk-rum-otele/references/blank-screen.md +190 -0
  22. package/skills/bk-rum-otele/references/capabilities.md +175 -83
  23. package/skills/bk-rum-otele/references/configuration.md +226 -151
  24. package/skills/bk-rum-otele/references/data-model.md +156 -24
  25. package/skills/bk-rum-otele/references/errors-security.md +168 -0
  26. package/skills/bk-rum-otele/references/extensions.md +236 -0
  27. package/skills/bk-rum-otele/references/framework-integration.md +318 -75
  28. package/skills/bk-rum-otele/references/getting-started.md +186 -70
  29. package/skills/bk-rum-otele/references/network.md +258 -0
  30. package/skills/bk-rum-otele/references/performance.md +197 -0
  31. package/skills/bk-rum-otele/references/privacy.md +236 -67
  32. package/skills/bk-rum-otele/references/production.md +264 -0
  33. package/skills/bk-rum-otele/references/session-context.md +185 -0
  34. package/skills/bk-rum-otele/references/telemetry-reference.md +479 -51
  35. package/skills/bk-rum-otele/references/transport-sampling.md +318 -32
  36. package/skills/bk-rum-otele/references/troubleshooting.md +341 -151
  37. package/skills/bk-rum-otele/references/views-routing.md +211 -0
  38. package/skills/bk-rum-otele/references/concepts.md +0 -60
  39. package/skills/bk-rum-otele/references/custom-plugin.md +0 -170
  40. package/skills/bk-rum-otele/references/plugins-basic.md +0 -135
  41. package/skills/bk-rum-otele/references/plugins-error-security.md +0 -83
  42. package/skills/bk-rum-otele/references/plugins-experience.md +0 -124
  43. package/skills/bk-rum-otele/references/plugins-network.md +0 -32
  44. package/skills/bk-rum-otele/references/plugins.md +0 -62
@@ -3,6 +3,7 @@ import type { BkOTBlankScreenPluginOptions } from '../plugins/blank-screen';
3
3
  import type { BkOTDevicePluginOptions } from '../plugins/device';
4
4
  import type { BkOTLongTaskPluginOptions } from '../plugins/long-task';
5
5
  import type { BkOTSessionConfig } from '../plugins/session';
6
+ import type { RumRequestOutcome } from '../schema/span';
6
7
  import type { BkOTPlugin } from './plugin';
7
8
  import type { BkOTUserContext } from './runtime-context';
8
9
  import type { Attributes } from '@opentelemetry/api';
@@ -71,6 +72,7 @@ export interface BkOTRequestConfig {
71
72
  excludedUrls?: BkOTUrlMatcher | BkOTUrlMatcher[];
72
73
  beforeSend?: (event: BkOTRequestEvent, context: BkOTRequestContext) => boolean | void;
73
74
  }
75
+ export type BkOTRequestOutcome = RumRequestOutcome;
74
76
  export type BkOTRequestContext = {
75
77
  error?: unknown;
76
78
  request: Request | RequestInit;
@@ -85,8 +87,8 @@ export interface BkOTRequestEvent {
85
87
  type: 'resource';
86
88
  resource: {
87
89
  method?: string;
88
- statusCode?: number;
89
- type: 'fetch' | 'xhr';
90
+ outcome: BkOTRequestOutcome;
91
+ transport: 'fetch' | 'xhr';
90
92
  url?: string;
91
93
  };
92
94
  }
@@ -1,7 +1,7 @@
1
1
  import type { ResolvedBkOTConfig } from './config';
2
- import type { Attributes, Context } from '@opentelemetry/api';
2
+ import type { Attributes, Context, Span as ApiSpan } from '@opentelemetry/api';
3
3
  import type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-base';
4
- export declare const REQUEST_DISCARD_ATTRIBUTE = "bk.rum.request.discard";
4
+ export declare const markSpanDiscarded: (span: ApiSpan) => void;
5
5
  /**
6
6
  * 给所有 span 固化创建时的运行时上下文,并在 onEnd 阶段过滤自身上报请求和无 RUM 上下文 span。
7
7
  */
@@ -51,6 +51,8 @@ export declare class RumRuntimeContext {
51
51
  private readonly queuedViewCommands;
52
52
  private recordAssociation;
53
53
  private readonly sessionHistory;
54
+ private sampled;
55
+ private readonly samplingHistory;
54
56
  private readonly sessionLifecycleListeners;
55
57
  private readonly setOptionalAttribute;
56
58
  private user;
@@ -66,6 +68,7 @@ export declare class RumRuntimeContext {
66
68
  getUser: () => BkOTUserContext;
67
69
  getView: () => BkOTViewContext;
68
70
  isSessionActive: () => boolean;
71
+ isSessionSampledAt: (timestamp: number) => boolean;
69
72
  isViewActive: () => boolean;
70
73
  notifySessionLifecycle: (event: BkOTSessionLifecycleEvent) => void;
71
74
  onSessionLifecycle: (listener: (event: BkOTSessionLifecycleEvent) => void) => () => boolean;
@@ -73,6 +76,7 @@ export declare class RumRuntimeContext {
73
76
  onViewCommand: (listener: (command: BkOTViewCommand) => void) => () => boolean;
74
77
  setAttributes: (attributes: Attributes, changedAt?: number) => void;
75
78
  setUser: (user: BkOTUserContext) => void;
79
+ setSessionSampled: (sampled: boolean, changedAt?: number) => void;
76
80
  setView: (view: BkOTViewContext, changedAt?: number) => void;
77
81
  constructor(initialAttributes?: Attributes, user?: BkOTUserContext);
78
82
  }
@@ -1,5 +1,4 @@
1
1
  import type { ResolvedBkOTConfig } from './config';
2
- export declare const RUM_SAMPLED_ATTRIBUTE = "bk.rum.sampled";
3
2
  /**
4
3
  * 按应用和 RUM Session ID 做确定性采样。采样决定随 Session 更新,不再依赖 Tab 级 sessionStorage。
5
4
  */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type BkOTActionEventPayload, type BkOTApplicationConfig, type BkOTAttributesConfig, type BkOTAttributeValue, type BkOTBatchConfig, type BkOTBeforeSendEvent, type BkOTContextConfig, type BkOTCustomEventPayload, type BkOTExtensionsConfig, type BkOTOptions, type BkOTPrivacyConfig, type BkOTRequestConfig, type BkOTRequestContext, type BkOTRequestEvent, type BkOTTrackingConfig, type BkOTTrackingConsent, type BkOTTransportConfig, type BkOTUrlMatcher, type BkOTViewConfig, resolveConfig, type ResolvedApplicationConfig, type ResolvedBkOTConfig, type ResolvedConfigHooks, type ResolvedTransportConfig, type ResolvedViewConfig, } from './core/config';
1
+ export { type BkOTActionEventPayload, type BkOTApplicationConfig, type BkOTAttributesConfig, type BkOTAttributeValue, type BkOTBatchConfig, type BkOTBeforeSendEvent, type BkOTContextConfig, type BkOTCustomEventPayload, type BkOTExtensionsConfig, type BkOTOptions, type BkOTPrivacyConfig, type BkOTRequestConfig, type BkOTRequestContext, type BkOTRequestEvent, type BkOTRequestOutcome, type BkOTTrackingConfig, type BkOTTrackingConsent, type BkOTTransportConfig, type BkOTUrlMatcher, type BkOTViewConfig, resolveConfig, type ResolvedApplicationConfig, type ResolvedBkOTConfig, type ResolvedConfigHooks, type ResolvedTransportConfig, type ResolvedViewConfig, } from './core/config';
2
2
  export { type BkOTPlugin, type BkOTRuntimeContext, createPlugin, type PluginManager } from './core/plugin';
3
3
  export { FilteringSpanProcessor } from './core/processor';
4
4
  export { type BkOTSessionLifecycleEvent, type BkOTStartViewOptions, type BkOTUserContext, type BkOTViewContext, RumRuntimeContext, } from './core/runtime-context';
@@ -16,4 +16,4 @@ export { type BkOTSessionConfig, createSessionPlugin } from './plugins/session';
16
16
  export { createWebVitalsPlugin } from './plugins/web-vitals';
17
17
  export { createWebSocketPlugin } from './plugins/websocket';
18
18
  export { RUM_ATTRIBUTES, type RumAttributeKey } from './schema/attributes';
19
- export { buildRumSpanAttributes, RUM_SPAN_RESULT, RUM_SPAN_TYPE, type RumSpanClassification, type RumSpanResult, type RumSpanType, } from './schema/span';
19
+ export { buildRumSpanAttributes, RUM_SPAN_OUTCOME, RUM_SPAN_TYPE, type RumSpanClassification, type RumSpanOutcome, type RumSpanType, } from './schema/span';