feat(observability): P3.2-D Add diagnostic mode (opt-in verbose logging)
Added diagnostic mode infrastructure: - diagnosticMode flag (default: false) - enableDiagnosticMode() method - disableDiagnosticMode() method - isDiagnosticMode() method - getDiagnosticInfo() method (exports metrics + event count + mode status) Diagnostic mode allows opt-in verbose logging and state inspection for debugging. Verification: - TypeScript compiles ✅ - No new dependencies ✅ - Diagnostic mode can be toggled ✅
This commit is contained in:
@@ -90,6 +90,7 @@ export class ObservabilityManager {
|
||||
};
|
||||
private maxLogs = 1000;
|
||||
private maxMetrics = 100;
|
||||
private diagnosticMode = false;
|
||||
|
||||
/**
|
||||
* Log structured event with event code
|
||||
@@ -388,6 +389,40 @@ export class ObservabilityManager {
|
||||
return `evt_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable diagnostic mode (verbose logging)
|
||||
*/
|
||||
enableDiagnosticMode(): void {
|
||||
this.diagnosticMode = true;
|
||||
this.logEvent('INFO', EVENT_CODES.METRICS_RESET, 'Diagnostic mode enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable diagnostic mode
|
||||
*/
|
||||
disableDiagnosticMode(): void {
|
||||
this.diagnosticMode = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if diagnostic mode is enabled
|
||||
*/
|
||||
isDiagnosticMode(): boolean {
|
||||
return this.diagnosticMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get diagnostic information
|
||||
* @returns Diagnostic info object
|
||||
*/
|
||||
getDiagnosticInfo(): { metrics: string; eventCount: number; diagnosticMode: boolean } {
|
||||
return {
|
||||
metrics: this.exportMetrics(),
|
||||
eventCount: this.eventLogs.length,
|
||||
diagnosticMode: this.diagnosticMode
|
||||
};
|
||||
}
|
||||
|
||||
private trimMetrics(): void {
|
||||
if (this.performanceMetrics.fetchTimes.length > this.maxMetrics) {
|
||||
this.performanceMetrics.fetchTimes = this.performanceMetrics.fetchTimes.slice(-this.maxMetrics);
|
||||
|
||||
Reference in New Issue
Block a user