Class BatchOptions

java.lang.Object
codes.grow.packages.betterstack.logging.BatchOptions

public final class BatchOptions extends Object
Options of a BatchProcessor. Defaults: queue 2048 records, batches of at most 512 records and 1 MiB (UTF-8 JSON size), flush every second, 30 s export timeout, DropPolicy.DROP_NEWEST, gzip on, 2 export retries with 200 ms base backoff.
  • Method Details

    • defaults

      public static BatchOptions defaults()
      Returns the defaults.
      Returns:
      default options
    • builder

      public static BatchOptions.Builder builder()
      Returns a builder with the defaults.
      Returns:
      builder
    • toBuilder

      public BatchOptions.Builder toBuilder()
      Returns a builder initialised with these options.
      Returns:
      builder copy
    • maxQueueSize

      public int maxQueueSize()
      Maximum number of queued records (default 2048).
      Returns:
      queue size
    • maxBatchSize

      public int maxBatchSize()
      Maximum records per export (default 512).
      Returns:
      batch size
    • maxBatchBytes

      public int maxBatchBytes()
      Maximum UTF-8 JSON bytes per export (default 1 048 576). A single larger record is exported alone.
      Returns:
      batch bytes
    • flushInterval

      public Duration flushInterval()
      Interval of the background flush (default 1 s).
      Returns:
      interval
    • exportTimeout

      public Duration exportTimeout()
      Time budget per export including retries; also the default flush/shutdown timeout (default 30 s).
      Returns:
      timeout
    • dropPolicy

      public DropPolicy dropPolicy()
      Queue-full behaviour (default DropPolicy.DROP_NEWEST).
      Returns:
      policy
    • gzip

      public boolean gzip()
      Whether exports are gzipped (default true).
      Returns:
      gzip flag
    • maxExportRetries

      public int maxExportRetries()
      Export attempts repeated after a retryable failure (default 2).
      Returns:
      retries
    • retryBackoff

      public Duration retryBackoff()
      Base delay before a repeated export, doubled per attempt (default 200 ms).
      Returns:
      backoff
    • onDrop

      public BiConsumer<List<LogRecord>,DropReason> onDrop()
      Drop callback.
      Returns:
      callback (never null; no-op by default)
    • onError

      public BiConsumer<Throwable,List<LogRecord>> onError()
      Export error callback.
      Returns:
      callback (never null; no-op by default)
    • toString

      public String toString()
      Overrides:
      toString in class Object