Package io.jenkins.plugins.auditlogger
Class AuditLogStorage
java.lang.Object
io.jenkins.plugins.auditlogger.AuditLogStorage
Production-grade audit log storage.
Design for heavy load:
- Lock-free ConcurrentLinkedQueue for incoming events (zero blocking on callers)
- Single daemon writer thread drains queue and writes batches
- Persistent BufferedWriter (no open/close per entry)
- Bounded in-memory ring buffer (ArrayDeque + ReadWriteLock) for UI/API queries
- Automatic file rotation on size threshold
- Proper shutdown with flush guarantee
- Data masking integrated before persistence
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntry(AuditLogEntry entry) Record an audit event.filterEntries(String username, String action, Long startTime, Long endTime) Filter entries by criteria.voidflushNow()Force pending audit entries to be written immediately.Get all entries in memory (most recent MAX_ENTRIES_IN_MEMORY).Get the anomaly detector instance for querying alerts.static AuditLogStoragebooleanFast existence check used by the UI to avoid loading every entry during page render.voidInitialize storage: ensure dirs, load recent logs, start writer thread.voidshutdown()Flush all pending writes and shut down the writer thread.
-
Method Details
-
getInstance
-
initialize
public void initialize()Initialize storage: ensure dirs, load recent logs, start writer thread. Called once during plugin startup. -
addEntry
Record an audit event. Non-blocking — entry is queued for async disk write. Returns immediately; typical latency < 1 microsecond. -
getAllEntries
Get all entries in memory (most recent MAX_ENTRIES_IN_MEMORY). Returns a defensive copy. -
hasEntries
public boolean hasEntries()Fast existence check used by the UI to avoid loading every entry during page render. -
getAnomalyDetector
Get the anomaly detector instance for querying alerts. -
flushNow
public void flushNow()Force pending audit entries to be written immediately. Useful for events such as immediate restarts where the JVM may terminate before the scheduled writer thread gets its next flush window. -
filterEntries
public List<AuditLogEntry> filterEntries(String username, String action, Long startTime, Long endTime) Filter entries by criteria. Returns a defensive copy. -
shutdown
public void shutdown()Flush all pending writes and shut down the writer thread. Called on plugin stop.
-