/** * Real-time Metrics Collector for WordPress MCP Server * Integrates with existing client and cache systems */ import { PerformanceMonitor, PerformanceMetrics } from "./PerformanceMonitor.js"; import type { CacheStats } from "../cache/CacheManager.js"; import type { ClientStats } from "../types/client.js"; export interface CollectorConfig { enableRealTime: boolean; collectInterval: number; enableToolTracking: boolean; enableRequestInterception: boolean; enableCacheIntegration: boolean; enableSystemMetrics: boolean; } export interface RequestMetadata { toolName?: string; siteId?: string; endpoint: string; method: string; startTime: number; fromCache: boolean; } export interface ToolExecutionContext { toolName: string; parameters: Record; startTime: number; siteId: string | undefined; } /** * Metrics Collector - Central hub for all performance data */ export declare class MetricsCollector { private monitor; private config; private activeRequests; private activeTools; private clientInstances; private cacheManagers; private logger; private realTimeInterval?; constructor(monitor: PerformanceMonitor, config?: Partial); /** * Register a WordPress client for monitoring */ registerClient(siteId: string, client: unknown): void; /** * Register a cache manager for monitoring */ registerCacheManager(siteId: string, cacheManager: unknown): void; /** * Start tracking a tool execution */ startToolExecution(toolName: string, parameters: Record, siteId?: string): string; /** * End tool execution and record metrics */ endToolExecution(executionId: string, success: boolean, error?: Error): void; /** * Record a raw request (bypass tool tracking) */ recordRawRequest(responseTime: number, success: boolean, endpoint: string, fromCache?: boolean): void; /** * Collect current metrics from all sources */ collectCurrentMetrics(): PerformanceMetrics; /** * Get aggregated cache statistics */ getAggregatedCacheStats(): CacheStats; /** * Get aggregated client statistics */ getAggregatedClientStats(): ClientStats; /** * Get performance summary for specific site */ getSiteMetrics(siteId: string): { cache?: CacheStats; client?: ClientStats; isActive: boolean; }; /** * Generate performance comparison between sites */ compareSitePerformance(): { sites: string[]; comparison: Record; bestPerforming: string; worstPerforming: string; }; /** * Generate optimization suggestions */ generateOptimizationSuggestions(): { critical: string[]; recommended: string[]; optional: string[]; }; /** * Export detailed performance report */ exportDetailedReport(): { timestamp: string; overview: PerformanceMetrics; siteComparison: Record; aggregatedStats: { cache: CacheStats; client: ClientStats; }; optimizations: Record; alerts: unknown[]; }; /** * Start real-time metric collection */ private startRealTimeCollection; /** * Stop real-time collection and cleanup resources */ destroy(): void; /** * Update cache metrics in performance monitor */ private updateCacheMetrics; /** * Update client metrics in performance monitor */ private updateClientMetrics; /** * Intercept client requests for automatic tracking */ private interceptClientRequests; /** * Stop all monitoring and cleanup */ stop(): void; } //# sourceMappingURL=MetricsCollector.d.ts.map