@454creative/easy-email
Version:
A framework-agnostic email service library for Node.js with observability and monitoring
66 lines • 1.84 kB
TypeScript
/**
* Performance monitoring utilities for the email library
*/
export interface PerformanceMetrics {
operation: string;
duration: number;
timestamp: Date;
success: boolean;
error: string | undefined;
metadata: Record<string, any> | undefined;
}
export interface PerformanceConfig {
enabled: boolean;
thresholdMs: number;
logSlowOperations: boolean;
trackMemoryUsage: boolean;
}
export declare class PerformanceMonitor {
private static instance;
private metrics;
private config;
private startTimes;
private metadataStore;
private constructor();
static getInstance(config?: Partial<PerformanceConfig>): PerformanceMonitor;
/**
* Start timing an operation
*/
startOperation(operation: string, metadata?: Record<string, any>): void;
/**
* End timing an operation and record metrics
*/
endOperation(operation: string, success: boolean, error?: string): PerformanceMetrics | null;
/**
* Get performance summary
*/
getSummary(): {
totalOperations: number;
averageDuration: number;
slowOperations: PerformanceMetrics[];
successRate: number;
topOperations: Array<{
operation: string;
count: number;
avgDuration: number;
}>;
};
/**
* Clear all metrics
*/
clearMetrics(): void;
/**
* Get all metrics
*/
getMetrics(): PerformanceMetrics[];
/**
* Update configuration
*/
updateConfig(config: Partial<PerformanceConfig>): void;
private getMetadata;
}
/**
* Performance decorator for methods
*/
export declare function trackPerformance(operationName?: string): (target: any, propertyName: string, descriptor: PropertyDescriptor) => void;
//# sourceMappingURL=performance.d.ts.map