import { DetailedError, ErrorCategory, ErrorSeverity } from './error-handler'; /** * Interfaz para métricas de error */ export interface ErrorMetric { timestamp: number; category: ErrorCategory; severity: ErrorSeverity; code: string; message: string; context?: Record; resolved: boolean; resolutionTime?: number; recoveryAttempted: boolean; recoverySuccessful: boolean; } /** * Estadísticas agregadas de errores */ export interface ErrorStats { total: number; byCategory: Record; bySeverity: Record; byCode: Record; resolved: number; unresolved: number; averageResolutionTime: number; recoverySuccessRate: number; topErrors: Array<{ code: string; count: number; lastOccurrence: number; }>; trends: { hourly: number[]; daily: number[]; weekly: number[]; }; } /** * Configuración de alertas */ export interface AlertConfig { enabled: boolean; thresholds: { criticalErrorsPerHour: number; highErrorsPerHour: number; totalErrorsPerHour: number; recoveryFailureRate: number; }; notifications: { email?: string[]; webhook?: string; slack?: string; }; } /** * Motor de métricas y monitoreo de errores */ export declare class ErrorMetricsEngine { private static metrics; private static maxMetrics; private static alertConfig; private static testMode; /** * Registra una nueva métrica de error */ static recordError(error: DetailedError, context?: Record): void; /** * Marca un error como resuelto */ static markResolved(errorCode: string, timestamp: number): void; /** * Obtiene estadísticas completas */ static getStats(timeRange?: { start: number; end: number; }): ErrorStats; /** * Obtiene métricas por categoría */ static getMetricsByCategory(category: ErrorCategory, limit?: number): ErrorMetric[]; /** * Obtiene métricas por severidad */ static getMetricsBySeverity(severity: ErrorSeverity, limit?: number): ErrorMetric[]; /** * Exporta métricas en formato JSON */ static exportMetrics(format?: 'json' | 'csv'): string; /** * Limpia métricas antiguas */ static cleanupOldMetrics(maxAge?: number): void; /** * Configura alertas */ static configureAlerts(config: Partial): void; /** * Obtiene la configuración actual de alertas */ static getAlertConfig(): AlertConfig; /** * Habilita el modo test (reduce alertas) */ static enableTestMode(): void; /** * Deshabilita el modo test (restaura alertas) */ static disableTestMode(): void; /** * Verifica si está en modo test */ static isTestMode(): boolean; private static addMetric; private static groupByCategory; private static groupBySeverity; private static groupByCode; private static calculateAverageResolutionTime; private static calculateRecoverySuccessRate; private static getTopErrors; private static calculateTrends; private static exportToCSV; private static checkAlerts; private static triggerAlert; } /** * Utilidades para análisis de métricas */ export declare class MetricsAnalyzer { /** * Detecta patrones anómalos en los errores */ static detectAnomalies(timeRange?: { start: number; end: number; }): Array<{ type: string; description: string; severity: 'low' | 'medium' | 'high'; recommendation: string; }>; /** * Genera reporte de salud del sistema */ static generateHealthReport(): { score: number; status: 'excellent' | 'good' | 'warning' | 'critical'; summary: string; recommendations: string[]; }; } //# sourceMappingURL=error-metrics.d.ts.map