UNPKG

@ai-capabilities-suite/mcp-debugger-core

Version:

Core debugging engine for Node.js and TypeScript applications. Provides Inspector Protocol integration, breakpoint management, variable inspection, execution control, profiling, hang detection, and source map support.

142 lines (141 loc) 3.51 kB
/** * Metric types for tracking different aspects of the debugger */ export declare enum MetricType { SESSION_DURATION = "session_duration", SESSION_COUNT = "session_count", BREAKPOINT_HIT = "breakpoint_hit", OPERATION_LATENCY = "operation_latency", ERROR_RATE = "error_rate" } /** * Metric entry for tracking */ export interface MetricEntry { type: MetricType; timestamp: number; value: number; labels?: Record<string, string>; } /** * Aggregated metric statistics */ export interface MetricStats { count: number; sum: number; min: number; max: number; avg: number; p50?: number; p95?: number; p99?: number; } /** * Metrics summary by type */ export interface MetricsSummary { [key: string]: MetricStats; } /** * Metrics collector for enterprise observability * Tracks session metrics, operation latencies, and error rates */ export declare class MetricsCollector { private metrics; private sessionStartTimes; private breakpointHitCounts; private operationStartTimes; private errorCounts; private readonly maxMetricsSize; /** * Record a session start */ recordSessionStart(sessionId: string): void; /** * Record a session end and calculate duration */ recordSessionEnd(sessionId: string): void; /** * Record a breakpoint hit */ recordBreakpointHit(breakpointId: string, sessionId?: string): void; /** * Start tracking an operation */ startOperation(operationId: string, operationType: string): void; /** * End tracking an operation and record latency */ endOperation(operationId: string, operationType: string, success?: boolean): void; /** * Record an error */ recordError(errorType: string): void; /** * Record a generic metric */ private recordMetric; /** * Get all metrics */ getAllMetrics(): MetricEntry[]; /** * Get metrics by type */ getMetricsByType(type: MetricType): MetricEntry[]; /** * Get metrics within a time range */ getMetricsInRange(startTime: number, endTime: number): MetricEntry[]; /** * Calculate statistics for a set of metrics */ private calculateStats; /** * Get summary statistics for all metrics */ getSummary(): MetricsSummary; /** * Get active session count */ getActiveSessionCount(): number; /** * Get breakpoint hit count for a specific breakpoint */ getBreakpointHitCount(breakpointId: string): number; /** * Get all breakpoint hit counts */ getAllBreakpointHitCounts(): Map<string, number>; /** * Get error count for a specific error type */ getErrorCount(errorType: string): number; /** * Get all error counts */ getAllErrorCounts(): Map<string, number>; /** * Get total error count */ getTotalErrorCount(): number; /** * Clear all metrics */ clearMetrics(): void; /** * Export metrics in a format suitable for external monitoring systems */ exportMetrics(): { metrics: MetricEntry[]; summary: MetricsSummary; activeSessionCount: number; breakpointHitCounts: Record<string, number>; errorCounts: Record<string, number>; totalErrors: number; }; /** * Get metrics endpoint data (for HTTP endpoint) */ getMetricsEndpointData(): string; }