UNPKG

finops-mcp-server

Version:

MCP server for FinOps Center cost optimization integration

100 lines 2.92 kB
/** * Performance Monitoring Utility * * This module provides performance monitoring functionality for the FinOps MCP Server. * It tracks API response times, success rates, authentication metrics, and request patterns. */ import { Logger, PerformanceMetrics, OperationMetrics } from "../types/config"; /** * Performance Monitor class for tracking metrics */ export declare class PerformanceMonitor { private data; private logger; private metricsInterval?; private readonly maxRequestHistory; private readonly maxDurationHistory; constructor(logger: Logger); /** * Start performance monitoring with periodic metrics logging */ start(intervalMs?: number): void; /** * Stop performance monitoring */ stop(): void; /** * Record a request metric */ recordRequest(operation: string, duration: number, success: boolean, statusCode?: number, errorType?: string): void; /** * Record authentication attempt */ recordAuthAttempt(success: boolean, reason?: string): void; /** * Get current performance metrics */ getMetrics(): PerformanceMetrics; /** * Get operation-specific metrics */ getOperationMetrics(): OperationMetrics[]; /** * Get authentication metrics */ getAuthMetrics(): { totalAttempts: number; successfulAttempts: number; failedAttempts: number; successRate: number; lastFailureTime: string | undefined; failureReasons: { [k: string]: number; }; }; /** * Reset all metrics */ reset(): void; /** * Get request patterns analysis */ getRequestPatterns(): { totalRequests: number; operationCounts: { [k: string]: number; }; errorsByOperation: { [k: string]: number; }; errorsByType: { [k: string]: number; }; timeWindow: string; }; /** * Update operation-specific metrics */ private updateOperationMetrics; /** * Calculate percentile from sorted array */ private calculatePercentile; /** * Log current metrics */ private logMetrics; } /** * Create a performance monitor instance */ export declare function createPerformanceMonitor(logger: Logger): PerformanceMonitor; /** * Decorator for measuring function execution time */ export declare function measurePerformance(monitor: PerformanceMonitor, operation: string): <T extends (...args: any[]) => Promise<any>>(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>; /** * Utility function to measure async operations */ export declare function measureAsync<T>(monitor: PerformanceMonitor, operation: string, fn: () => Promise<T>): Promise<T>; //# sourceMappingURL=performance-monitor.d.ts.map