/** * 上下文信息提取器 * 从ContextProvider获取请求相关的上下文信息 */ export declare class ContextExtractor { /** * 获取完整的HTTP请求上下文 */ static getHttpContext(): { requestId?: string; userId?: string; clientIp?: string; userAgent?: string; appId?: string; metadata?: Record; tags?: string[]; }; /** * 获取请求ID */ static getRequestId(): string | undefined; /** * 获取用户ID */ static getUserId(): string | undefined; /** * 获取客户端IP */ static getClientIp(): string | undefined; /** * 获取用户代理 * 注意:当前 ContextProvider 不存储 userAgent 信息 * 如需使用此功能,需要扩展 ContextProvider 或从请求头中获取 */ static getUserAgent(): string | undefined; /** * 获取服务名称 */ static getServiceName(): string | undefined; /** * 获取元数据 */ static getMetadata(): Record | undefined; /** * 获取标签 */ static getTags(): string[]; /** * 添加标签到上下文 */ static addTag(tag: string): void; /** * 获取上下文摘要 */ static getContextSummary(): { requestId?: string; userId?: string; service?: string; clientIp?: string; hasUser: boolean; requestSource: string; }; /** * 获取请求来源信息 */ static getRequestSource(): { source: 'internal' | 'external' | 'unknown'; ip?: string; userAgent?: string; service?: string; }; /** * 判断是否为内部请求 */ static isInternalRequest(): boolean; /** * 获取安全上下文 */ static getSecurityContext(): { isAuthenticated: boolean; userId?: string; tenantId?: string; role?: string; permissions: string[]; securityLevel: 'low' | 'medium' | 'high'; }; /** * 生成Span ID */ private static generateSpanId; /** * 检查172.x.x.x是否为内网IP (172.16.0.0 - 172.31.255.255) */ private static isInternal172IP; }