/** * @file Metrics Collection System * @version 1.0.0 * @status STABLE - DO NOT MODIFY WITHOUT TESTS * @lastModified 2024-06-07 * * Simple metrics collection for monitoring performance * * IMPORTANT: * - Keep metrics collection lightweight * - Use consistent naming conventions * * Functionality: * - Request counting * - Timing measurements * - Error tracking */ export declare class Metrics { private static instance; private counters; private timers; private errors; private startTimes; private constructor(); static getInstance(): Metrics; /** * Increment a counter metric * @param name Metric name * @param amount Amount to increment (default: 1) */ incrementCounter(name: string, amount?: number): void; /** * Get the current value of a counter * @param name Metric name * @returns Current counter value */ getCounter(name: string): number; /** * Start timing an operation * @param name Metric name */ startTimer(name: string): void; /** * End timing an operation and record the duration * @param name Metric name * @returns Duration in milliseconds */ endTimer(name: string): number; /** * Record a time measurement directly * @param name Metric name * @param duration Duration in milliseconds */ recordTime(name: string, duration: number): void; /** * Get timing statistics for a metric * @param name Metric name * @returns Timing statistics */ getTimer(name: string): { avg: number; min: number; max: number; count: number; last: number; } | null; /** * Record an error * @param category Error category * @param error Error object or message */ recordError(category: string, error: Error | string): void; /** * Get error statistics for a category * @param category Error category * @returns Error statistics */ getErrorStats(category: string): { count: number; last: Error | string; lastTime: number; } | null; /** * Reset all metrics */ reset(): void; /** * Get a snapshot of all metrics * @returns Metrics snapshot */ getSnapshot(): Record; } export declare const metrics: Metrics; export declare function timeAsync(name: string, fn: () => Promise): Promise; export declare function trackApiCall(method: string): void;