Class InMemoryLogExporter

java.lang.Object
codes.grow.packages.skywalking.testing.logging.InMemoryLogExporter
All Implemented Interfaces:
LogExporter

public final class InMemoryLogExporter extends Object implements LogExporter
  • Constructor Details

    • InMemoryLogExporter

      public InMemoryLogExporter()
      Creates an empty exporter.
  • Method Details

    • enqueueOutcome

      public void enqueueOutcome(Function<List<LogRecord>,CompletableFuture<ExportResult>> outcome)
      Scripts the outcome of the next export call (FIFO). Without a scripted outcome every record is accepted and stored.
      Parameters:
      outcome - receives the batch and returns the export future
    • export

      public CompletableFuture<ExportResult> export(List<LogRecord> batch, ExportOptions options)
      Description copied from interface: LogExporter
      Exports a batch. The future completes with the accepted/rejected counts; it may also complete exceptionally (treated as "all rejected"). Cancelling the future cancels the export.
      Specified by:
      export in interface LogExporter
      Parameters:
      batch - records to send (never empty)
      options - gzip flag and time budget
      Returns:
      the export result
    • store

      public void store(List<LogRecord> accepted)
      Stores records as if exported (for outcomes that accept part of a batch).
      Parameters:
      accepted - records to store
    • shutdown

      public CompletableFuture<Void> shutdown()
      Description copied from interface: LogExporter
      Releases resources. Called once by BatchProcessor.shutdown.
      Specified by:
      shutdown in interface LogExporter
      Returns:
      completes when the exporter is closed
    • records

      public List<LogRecord> records()
      Accepted records in export order.
      Returns:
      copy of the records
    • batchSizes

      public List<Integer> batchSizes()
      Sizes of all export calls.
      Returns:
      batch sizes
    • gzipFlags

      public List<Boolean> gzipFlags()
      Gzip flags of all export calls.
      Returns:
      flags
    • shutdownCount

      public int shutdownCount()
      Number of shutdown() calls.
      Returns:
      count
    • reset

      public void reset()
      Forgets stored records and statistics (scripted outcomes stay).