@accordkit/tracer - v0.2.1
    Preparing search index...

    Interface Sink

    A destination for AccordKit trace events.

    Sinks are responsible for persisting trace events to various destinations like files, databases, or remote services. They serve as pluggable backends for the tracing system.

    Implementation guidelines:

    • Make implementations resilient and non-throwing by default
    • Favor local-first behavior for offline/development workflows
    • Handle errors gracefully without disrupting the application
    • Consider implementing BufferedSink for better performance
    // A simple sink that logs events to the console.
    class ConsoleSink implements Sink {
    write(sessionId: string, e: TracerEvent): void {
    const { type, level } = e;
    console.log(`[${sessionId}] ${level} - ${type}`);
    }
    }

    const sink = new ConsoleSink();
    // sink.write('session-123', { ... });
    
    
    interface Sink {
        write(sessionId: string, e: TracerEvent): void | Promise<void>;
    }

    Hierarchy (View Summary)

    Index

    Methods

    Methods

    • Persist a single event for a session.

      Parameters

      • sessionId: string

        Unique identifier for grouping related events. Used for partitioning and log file naming.

      • e: TracerEvent

        The trace event to persist. See TracerEvent for structure.

      Returns void | Promise<void>

      Void or Promise for async implementations.

      Implementations should:

      • Handle errors gracefully without throwing
      • Consider batching for performance if needed
      • Maintain order of events within a session
      • Be thread-safe if used in concurrent environments