mushcode-mcp-server
Version:
A specialized Model Context Protocol server for MUSHCODE development assistance. Provides AI-powered code generation, validation, optimization, and examples for MUD development.
122 lines • 3.48 kB
TypeScript
/**
* Performance monitoring and metrics collection
* Tracks response times, operation counts, and system performance
*/
export interface PerformanceMetric {
operation: string;
duration: number;
timestamp: number;
success: boolean;
metadata?: Record<string, any>;
}
export interface PerformanceStats {
operation: string;
count: number;
totalDuration: number;
averageDuration: number;
minDuration: number;
maxDuration: number;
successRate: number;
recentDurations: number[];
p95Duration: number;
p99Duration: number;
}
export interface SystemMetrics {
memoryUsage: NodeJS.MemoryUsage;
uptime: number;
timestamp: number;
}
/**
* Performance monitor for tracking operation metrics
*/
export declare class PerformanceMonitor {
private static instance;
private metrics;
private maxMetrics;
private alertThresholds;
private systemMetricsHistory;
private maxSystemMetrics;
private constructor();
static getInstance(): PerformanceMonitor;
/**
* Record a performance metric
*/
recordMetric(operation: string, duration: number, success?: boolean, metadata?: Record<string, any>): void;
/**
* Start a performance timer
*/
startTimer(operation: string, metadata?: Record<string, any>): (success?: boolean) => void;
/**
* Get performance statistics for an operation
*/
getOperationStats(operation: string, timeWindowMs?: number): PerformanceStats | undefined;
/**
* Get statistics for all operations
*/
getAllOperationStats(timeWindowMs?: number): PerformanceStats[];
/**
* Get operations that are performing poorly
*/
getSlowOperations(thresholdMs?: number): Array<{
operation: string;
stats: PerformanceStats;
}>;
/**
* Set alert threshold for an operation
*/
setAlertThreshold(operation: string, thresholdMs: number): void;
/**
* Get current system metrics
*/
getCurrentSystemMetrics(): SystemMetrics;
/**
* Get system metrics history
*/
getSystemMetricsHistory(count?: number): SystemMetrics[];
/**
* Get performance summary
*/
getPerformanceSummary(timeWindowMs?: number): {
operations: PerformanceStats[];
systemMetrics: SystemMetrics;
alerts: Array<{
operation: string;
issue: string;
value: number;
threshold: number;
}>;
totalRequests: number;
averageResponseTime: number;
errorRate: number;
};
/**
* Clear all metrics
*/
clearMetrics(): void;
/**
* Export metrics for analysis
*/
exportMetrics(timeWindowMs?: number): {
metrics: PerformanceMetric[];
systemMetrics: SystemMetrics[];
exportTime: number;
};
/**
* Calculate percentile from sorted array
*/
private calculatePercentile;
/**
* Check if operation duration exceeds alert threshold
*/
private checkPerformanceAlert;
/**
* Start collecting system metrics periodically
*/
private startSystemMetricsCollection;
}
/**
* Decorator for automatic performance monitoring
*/
export declare function monitorPerformance(operation?: string): (target: any, propertyName: string, descriptor: PropertyDescriptor) => void;
export declare const performanceMonitor: PerformanceMonitor;
//# sourceMappingURL=performance.d.ts.map