supa-seed
Version:
A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support
119 lines • 3.64 kB
TypeScript
/**
* Performance Monitoring System
* Phase 6, Checkpoint F1 - Comprehensive performance tracking and optimization
*/
export interface PerformanceMetric {
name: string;
value: number;
unit: 'ms' | 'mb' | 'count' | 'percentage' | 'bytes/sec';
timestamp: Date;
tags: Record<string, string>;
metadata?: Record<string, any>;
}
export interface OperationTiming {
operationName: string;
component: string;
startTime: number;
endTime?: number;
duration?: number;
memoryUsage?: {
before: NodeJS.MemoryUsage;
after?: NodeJS.MemoryUsage;
delta?: Partial<NodeJS.MemoryUsage>;
};
success: boolean;
errorCode?: string;
metadata?: Record<string, any>;
}
export declare class PerformanceMonitor {
private static metrics;
private static activeOperations;
private static performanceThresholds;
private static readonly MAX_METRICS_HISTORY;
/**
* Initialize performance monitoring with default thresholds
*/
static initialize(): void;
/**
* Start timing an operation
*/
static startOperation(operationName: string, component: string, metadata?: Record<string, any>): string;
/**
* End timing an operation
*/
static endOperation(operationId: string, success?: boolean, errorCode?: string, additionalMetadata?: Record<string, any>): OperationTiming | null;
/**
* Record a custom metric
*/
static recordMetric(metric: PerformanceMetric): void;
/**
* Set performance threshold for an operation
*/
static setThreshold(operationKey: string, thresholdMs: number): void;
/**
* Check if operation exceeded performance threshold
*/
private static checkPerformanceThreshold;
/**
* Get performance recommendation based on timing
*/
private static getPerformanceRecommendation;
/**
* Check if metric is significant enough to log
*/
private static isSignificantMetric;
/**
* Get performance statistics
*/
static getPerformanceStats(): {
totalOperations: number;
averageResponseTime: number;
slowestOperations: Array<{
operation: string;
duration: number;
timestamp: Date;
}>;
memoryTrends: Array<{
timestamp: Date;
heapUsed: number;
component: string;
}>;
errorRate: number;
componentPerformance: Record<string, {
averageDuration: number;
operationCount: number;
errorCount: number;
}>;
};
/**
* Get system resource usage
*/
static getSystemStats(): {
memory: NodeJS.MemoryUsage;
uptime: number;
activeOperations: number;
cpuUsage?: NodeJS.CpuUsage;
};
/**
* Clear metrics history
*/
static clearMetrics(): void;
/**
* Export metrics for external monitoring
*/
static exportMetrics(format?: 'json' | 'prometheus'): string;
/**
* Format metrics in Prometheus format
*/
private static formatPrometheusMetrics;
}
/**
* Performance monitoring decorator
*/
export declare function monitor(component: string, operationName?: string): (target: any, propertyName: string, descriptor: PropertyDescriptor) => void;
/**
* Async wrapper for performance monitoring
*/
export declare function withPerformanceMonitoring<T>(operation: () => Promise<T>, component: string, operationName: string, metadata?: Record<string, any>): Promise<T>;
export default PerformanceMonitor;
//# sourceMappingURL=performance-monitor.d.ts.map