/** * Metrics collector for comprehensive observability. * * Tracks timing, token usage, errors, and costs across all operations. */ import type { TokenUsageRecord, TimingRecord, ErrorRecord, CostRecord, OperationType, ErrorCategory, InterviewMetrics, AggregatedMetrics, DashboardMetrics } from './types.js'; /** * Options for the metrics collector. */ export interface MetricsCollectorOptions { /** Maximum number of records to keep in memory */ maxRecords?: number; /** Whether to track individual records (vs just aggregates) */ trackRecords?: boolean; } /** * Centralized metrics collector for observability. */ export declare class MetricsCollector { private readonly options; private tokenRecords; private timingRecords; private errorRecords; private costRecords; private tokensByProviderModel; private timingByOperation; private errorsByCategory; private costByProvider; private interviewMetrics; constructor(options?: MetricsCollectorOptions); /** * Start tracking an interview. */ startInterview(): void; /** * End interview tracking. */ endInterview(): InterviewMetrics | null; /** * Record token usage from an LLM call. */ recordTokenUsage(provider: string, model: string, inputTokens: number, outputTokens: number, operation?: string): void; /** * Record operation timing. */ recordTiming(operation: OperationType, durationMs: number, success: boolean, metadata?: Record): void; /** * Record an error. */ recordError(category: ErrorCategory, code: string, message: string, retryable: boolean, operation?: string): void; /** * Update interview-specific counters. */ updateInterviewCounters(updates: Partial<{ toolsDiscovered: number; questionsGenerated: number; personasUsed: number; }>): void; /** * Create a timed operation wrapper. */ time(operation: OperationType, fn: () => Promise, metadata?: Record): Promise; /** * Get current interview metrics. */ getInterviewMetrics(): InterviewMetrics | null; /** * Get aggregated metrics for a time period. */ getAggregatedMetrics(periodStart?: Date, periodEnd?: Date): AggregatedMetrics; /** * Get dashboard-compatible metrics. */ getDashboardMetrics(): DashboardMetrics; /** * Reset all metrics. */ reset(): void; /** * Get raw records for external processing. */ getRawRecords(): { tokens: TokenUsageRecord[]; timing: TimingRecord[]; errors: ErrorRecord[]; costs: CostRecord[]; }; private trimRecords; private calculateTokenUsageFromRecords; private calculateTokenUsageFromAggregates; private calculateOperationStatsFromRecords; private calculateOperationStatsFromAggregates; private convertOperationStats; private calculateErrorStatsFromRecords; private calculateErrorStatsFromAggregates; private calculateProjectedCost; } /** * Get or create the global metrics collector. */ export declare function getMetricsCollector(options?: MetricsCollectorOptions): MetricsCollector; /** * Reset the global metrics collector. */ export declare function resetMetricsCollector(): void; //# sourceMappingURL=collector.d.ts.map