import { AbstractUuidPrimaryEntity } from '../../common'; /** * HTTP请求日志实体 * 用于TypeORM数据库记录 */ export declare class HttpLogEntity extends AbstractUuidPrimaryEntity { /** * 请求ID(从ContextProvider获取) */ requestId?: string; /** * 用户ID(从ContextProvider获取) */ userId?: string; /** * HTTP方法 */ method: string; /** * 请求URL */ url: string; /** * 请求头信息(JSON格式) */ headers?: Record; /** * 请求体内容 */ body?: string; /** * 查询参数(JSON格式) */ params?: Record; /** * HTTP状态码 */ statusCode?: number; /** * 响应时间(毫秒) */ responseTime: number; /** * 尝试次数 */ attemptCount: number; /** * 是否成功 */ success: boolean; /** * 错误信息 */ errorMessage?: string; /** * 错误堆栈 */ errorStack?: string; /** * 错误代码 */ errorCode?: string; /** * 响应头信息(JSON格式) */ responseHeaders?: Record; /** * 响应体内容 */ responseBody?: string; /** * 服务名称(用于微服务环境) */ serviceName?: string; /** * 自定义操作名称(用于业务标识) */ operationName?: string; /** * 请求来源 */ source?: string; /** * 请求标签(用于分类) */ tags?: string[]; /** * 请求元数据(JSON格式) */ metadata?: Record; /** * 重试记录(JSON格式) */ retryRecords?: RetryRecord[]; /** * 熔断器状态 */ circuitBreakerState?: string; } /** * 重试记录接口 */ export interface RetryRecord { /** * 重试次数 */ attempt: number; /** * 重试时间 */ timestamp: Date; /** * 重试原因 */ reason: string; /** * 重试延迟(毫秒) */ delay: number; /** * 错误信息 */ error?: { message: string; code?: string; statusCode?: number; }; /** * 请求配置(简化版) */ requestConfig?: { method: string; url: string; headers: Record; }; } /** * HTTP日志查询选项 */ export interface HttpLogQueryOptions { /** * 请求ID */ requestId?: string; /** * 用户ID */ userId?: string; /** * HTTP方法 */ method?: string | string[]; /** * URL(支持模糊搜索) */ url?: string; /** * 状态码 */ statusCode?: number | number[]; /** * 是否成功 */ success?: boolean; /** * 服务名称 */ serviceName?: string; /** * 操作名称 */ operationName?: string; /** * 请求来源 */ source?: string; /** * 标签 */ tags?: string[]; /** * 错误代码 */ errorCode?: string; /** * 最小响应时间 */ minResponseTime?: number; /** * 最大响应时间 */ maxResponseTime?: number; /** * 开始时间 */ startDate?: Date; /** * 结束时间 */ endDate?: Date; /** * 搜索关键词 */ keyword?: string; /** * 分页参数 */ page?: number; /** * 每页数量 */ limit?: number; /** * 排序字段 */ sortBy?: 'createdAt' | 'responseTime' | 'statusCode' | 'url'; /** * 排序方向 */ sortOrder?: 'ASC' | 'DESC'; /** * 是否包含详细数据 */ includeDetails?: boolean; } /** * HTTP日志统计结果 */ export interface HttpLogStats { /** * 总请求数 */ totalRequests: number; /** * 成功请求数 */ successfulRequests: number; /** * 失败请求数 */ failedRequests: number; /** * 成功率 */ successRate: number; /** * 平均响应时间 */ averageResponseTime: number; /** * 最小响应时间 */ minResponseTime: number; /** * 最大响应时间 */ maxResponseTime: number; /** * P50响应时间 */ p50ResponseTime: number; /** * P95响应时间 */ p95ResponseTime: number; /** * P99响应时间 */ p99ResponseTime: number; /** * 按方法统计 */ requestsByMethod: Record; /** * 按状态码统计 */ requestsByStatus: Record; /** * 按服务统计 */ requestsByService: Record; /** * 按来源统计 */ requestsBySource: Record; /** * 错误统计 */ errorsByCode: Record; /** * 重试统计 */ retryStats: { totalRetries: number; averageRetries: number; maxRetries: number; retryRate: number; }; }