Package 

Class Tracer


  • 
    public final class Tracer
    
                        

    An append-only, thread-safe trace buffer that can be snapshotted and rolled back.

    All state mutations are guarded by lock, ensuring atomicity across threads.

    • Constructor Summary

      Constructors 
      Constructor Description
      Tracer(String id)
    • Method Summary

      Modifier and Type Method Description
      final Boolean isEnabled() Returns true if tracing is enabled, false otherwise.
      final <ERROR CLASS> setEnabled(Boolean enabled) Enables or disables tracing.
      final Unit trace(String tag, Object data) Records a trace entry when tracing is enabled.
      final TraceSlice take() Returns a snapshot of the current buffer and clears it.
      final <ERROR CLASS> dispose() Permanently discards all buffered trace entries.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • isEnabled

         final Boolean isEnabled()

        Returns true if tracing is enabled, false otherwise.

      • setEnabled

         final <ERROR CLASS> setEnabled(Boolean enabled)

        Enables or disables tracing.

        Switching state clears any existing buffered entries.

      • trace

         final Unit trace(String tag, Object data)

        Records a trace entry when tracing is enabled.

        The lambda form matches the original TypeScript API and can be stored or passed around as a function reference.

      • take

         final TraceSlice take()

        Returns a snapshot of the current buffer and clears it.

        The returned TraceSlice.rollback reinserts the snapshot at the front of the buffer, preserving original ordering.

      • dispose

         final <ERROR CLASS> dispose()

        Permanently discards all buffered trace entries.