/** * Context Manager - AsyncLocalStorage 기반 컨텍스트 관리 * * HTTP 요청 단위로 TraceID를 관리하고, 함수 호출 체인에서 * 동일한 컨텍스트를 공유할 수 있도록 합니다. */ /** * 함수 로깅 컨텍스트 */ export interface FunctionLogContext { /** 요청 추적 ID */ traceId: string; /** 현재 span ID (옵션) */ spanId?: string; /** 요청 ID (옵션) */ requestId?: string; /** 사용자 정의 메타데이터 */ metadata?: Record; } /** * Context Manager 인터페이스 */ export interface ContextManager { /** * 컨텍스트 내에서 콜백을 실행합니다. * @param context 컨텍스트 데이터 * @param callback 실행할 콜백 * @returns 콜백의 반환값 */ run(context: FunctionLogContext, callback: () => T): T; /** * 현재 컨텍스트를 반환합니다. * @returns 현재 컨텍스트 또는 undefined */ getStore(): FunctionLogContext | undefined; /** * 현재 TraceID를 반환합니다. * @returns TraceID 또는 undefined */ getTraceId(): string | undefined; /** * 현재 컨텍스트를 업데이트합니다. * @param updates 업데이트할 필드 */ updateStore(updates: Partial): void; } /** * Context Manager 인스턴스를 생성합니다. */ export declare function createContextManager(): ContextManager; /** * 기본 Context Manager를 반환합니다. * 싱글톤 패턴으로 구현되어 있습니다. */ export declare function getDefaultContextManager(): ContextManager; /** * 기본 Context Manager를 리셋합니다. * 주로 테스트에서 사용됩니다. */ export declare function resetDefaultContextManager(): void;