/** * Performance Monitor - Track agent performance metrics * * Provides latency, throughput, and error tracking for agents. */ /** * Metric types */ export type MetricType = 'counter' | 'gauge' | 'histogram' | 'timer'; /** * Metric entry */ export interface MetricEntry { name: string; type: MetricType; value: number; timestamp: number; labels?: Record; } /** * Timer result */ export interface TimerResult { duration: number; startTime: number; endTime: number; } /** * Performance stats */ export interface PerformanceStats { count: number; sum: number; min: number; max: number; avg: number; p50: number; p95: number; p99: number; } /** * Performance Monitor configuration */ export interface PerformanceMonitorConfig { /** Enable automatic collection */ autoCollect?: boolean; /** Collection interval in ms */ collectInterval?: number; /** Max entries to keep */ maxEntries?: number; /** Enable logging */ logging?: boolean; } /** * PerformanceMonitor - Track and analyze performance metrics */ export declare class PerformanceMonitor { readonly id: string; private metrics; private timers; private config; private intervalHandle?; constructor(config?: PerformanceMonitorConfig); /** * Increment a counter */ increment(name: string, value?: number, labels?: Record): void; /** * Set a gauge value */ gauge(name: string, value: number, labels?: Record): void; /** * Record a histogram value */ histogram(name: string, value: number, labels?: Record): void; /** * Start a timer */ startTimer(name: string): string; /** * Stop a timer and record duration */ stopTimer(timerId: string, labels?: Record): TimerResult; /** * Time an async function */ time(name: string, fn: () => Promise, labels?: Record): Promise; /** * Record a metric */ private record; /** * Get stats for a metric */ getStats(name: string, since?: number): PerformanceStats | null; /** * Get all metric names */ getMetricNames(): string[]; /** * Get recent entries */ getRecent(name: string, count?: number): MetricEntry[]; /** * Clear metrics */ clear(name?: string): void; /** * Export metrics */ export(): { metrics: Record; stats: Record; }; /** * Calculate percentile */ private percentile; /** * Start auto-collection */ private startAutoCollect; /** * Stop auto-collection */ stop(): void; } /** * Create performance monitor */ export declare function createPerformanceMonitor(config?: PerformanceMonitorConfig): PerformanceMonitor; export default PerformanceMonitor;