@lark-apaas/observable 1.0.1-alpha.9 → 1.0.2-alpha.2

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/dist/index.d.cts CHANGED
@@ -1,27 +1,33 @@
1
- interface RequestContext {
2
- trace_id?: string;
3
- user_id?: string | null;
4
- tenant_id?: string | null;
5
- app_id?: string | null;
6
- ip?: string | null;
7
- method?: string;
8
- path?: string;
9
- headers?: Record<string, string>;
10
- }
11
- declare function runWithRequestContext<T>(ctx: RequestContext, fn: () => T): T;
12
- declare function getRequestContext(): RequestContext | undefined;
13
- declare class AppOTelLoggerSDK {
1
+ import { MaybePromise } from '@opentelemetry/resources';
2
+ import { Span } from '@opentelemetry/api';
3
+ export { Span } from '@opentelemetry/api';
4
+ import { Observable } from 'rxjs';
5
+
6
+ declare class AppOTelSDK {
14
7
  private sdk;
15
8
  private logProcessor;
9
+ private spanProcessor;
10
+ private static CUSTOM_FORMAT_REGEX;
16
11
  start(): void;
17
12
  /**
18
- * 用户使用的日志接口
19
- * 自动合并请求级上下文
13
+ * [框架专用 API] 开启一个根 Span (Root Span)
14
+ * 该方法专供 Middleware/Interceptor 使用
15
+ */
16
+ startContext(headers: Record<string, string>, name: string, fn: (span: Span) => void): void;
17
+ /**
18
+ * [用户专用 API] 手动打点 (Child Span)
19
+ * 用户在 Service 中调用此方法,会自动挂载到 Middleware 创建的 Root Span 下
20
+ */
21
+ trace<T>(name: string, fn: (span: Span) => MaybePromise<T> | Observable<T>): MaybePromise<T> | Observable<T>;
22
+ /**
23
+ * [Log API] 自动关联 TraceContext
20
24
  */
21
25
  log(level: string, message: string, extra?: Record<string, unknown>): void;
26
+ /**
27
+ * [框架专用] 强制刷新
28
+ */
22
29
  flush(): Promise<void>;
23
- private mapSeverity;
24
30
  }
25
- declare const appSdk: AppOTelLoggerSDK;
31
+ declare const appSdk: AppOTelSDK;
26
32
 
27
- export { AppOTelLoggerSDK, appSdk, getRequestContext, runWithRequestContext };
33
+ export { AppOTelSDK, appSdk };
package/dist/index.d.ts CHANGED
@@ -1,27 +1,33 @@
1
- interface RequestContext {
2
- trace_id?: string;
3
- user_id?: string | null;
4
- tenant_id?: string | null;
5
- app_id?: string | null;
6
- ip?: string | null;
7
- method?: string;
8
- path?: string;
9
- headers?: Record<string, string>;
10
- }
11
- declare function runWithRequestContext<T>(ctx: RequestContext, fn: () => T): T;
12
- declare function getRequestContext(): RequestContext | undefined;
13
- declare class AppOTelLoggerSDK {
1
+ import { MaybePromise } from '@opentelemetry/resources';
2
+ import { Span } from '@opentelemetry/api';
3
+ export { Span } from '@opentelemetry/api';
4
+ import { Observable } from 'rxjs';
5
+
6
+ declare class AppOTelSDK {
14
7
  private sdk;
15
8
  private logProcessor;
9
+ private spanProcessor;
10
+ private static CUSTOM_FORMAT_REGEX;
16
11
  start(): void;
17
12
  /**
18
- * 用户使用的日志接口
19
- * 自动合并请求级上下文
13
+ * [框架专用 API] 开启一个根 Span (Root Span)
14
+ * 该方法专供 Middleware/Interceptor 使用
15
+ */
16
+ startContext(headers: Record<string, string>, name: string, fn: (span: Span) => void): void;
17
+ /**
18
+ * [用户专用 API] 手动打点 (Child Span)
19
+ * 用户在 Service 中调用此方法,会自动挂载到 Middleware 创建的 Root Span 下
20
+ */
21
+ trace<T>(name: string, fn: (span: Span) => MaybePromise<T> | Observable<T>): MaybePromise<T> | Observable<T>;
22
+ /**
23
+ * [Log API] 自动关联 TraceContext
20
24
  */
21
25
  log(level: string, message: string, extra?: Record<string, unknown>): void;
26
+ /**
27
+ * [框架专用] 强制刷新
28
+ */
22
29
  flush(): Promise<void>;
23
- private mapSeverity;
24
30
  }
25
- declare const appSdk: AppOTelLoggerSDK;
31
+ declare const appSdk: AppOTelSDK;
26
32
 
27
- export { AppOTelLoggerSDK, appSdk, getRequestContext, runWithRequestContext };
33
+ export { AppOTelSDK, appSdk };