A lightweight, thread-safe diagnostics library for tracking and troubleshooting application operations, with a focus on configuration validation and error tracking. This library provides structured diagnostic events with metadata, context data, and proper error handling.
public void usage() {
// Generate a request ID
String requestId = DiagnosticsUtil.generateRequestId();
// Enable diagnostics for a topic
DiagnosticsUtil.enableTopic("VECTOR_DB");
// Create metadata for the request
DiagnosticsMetadata metadata = DiagnosticsMetadata.of("VECTOR_DB", "BULK_LOAD", requestId);
// Log operation start with context data
Map<String, Object> params = Map.of("configParam", "value");
DiagnosticsUtil.info(metadata, "STARTED", "Operation started", params);
try {
// Perform operation...
DiagnosticsUtil.info(metadata, "COMPLETED", "Operation completed successfully");
} catch (Exception e) {
DiagnosticsUtil.error(metadata, "FAILED", "Operation failed", e);
throw e;
}
// Get diagnostic summary
String summary = DiagnosticsUtil.getDiagnosticSummary("VECTOR_DB");
System.out.println(summary);
}
The library includes comprehensive documentation to help you get started and understand the detailed behavior:
The main entry point for diagnostics operations, providing methods to:
Immutable record containing metadata for diagnostic events:
Support for tracking diagnostic events in reactive streams (Mono/Flux), with methods to: