Class InMemoryLogExporter
java.lang.Object
codes.grow.packages.skywalking.testing.logging.InMemoryLogExporter
- All Implemented Interfaces:
LogExporter
LogExporter that keeps every accepted record in memory. Scripted outcomes (enqueueOutcome(java.util.function.Function<java.util.List<codes.grow.packages.skywalking.logging.LogRecord>, java.util.concurrent.CompletableFuture<codes.grow.packages.skywalking.logging.ExportResult>>)) let tests simulate failures, partial acceptance and slow exports.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSizes of all export calls.voidenqueueOutcome(Function<List<LogRecord>, CompletableFuture<ExportResult>> outcome) Scripts the outcome of the next export call (FIFO).export(List<LogRecord> batch, ExportOptions options) Exports a batch.Gzip flags of all export calls.records()Accepted records in export order.voidreset()Forgets stored records and statistics (scripted outcomes stay).shutdown()Releases resources.intNumber ofshutdown()calls.voidStores records as if exported (for outcomes that accept part of a batch).
-
Constructor Details
-
InMemoryLogExporter
public InMemoryLogExporter()Creates an empty exporter.
-
-
Method Details
-
enqueueOutcome
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
Description copied from interface:LogExporterExports 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:
exportin interfaceLogExporter- Parameters:
batch- records to send (never empty)options- gzip flag and time budget- Returns:
- the export result
-
store
Stores records as if exported (for outcomes that accept part of a batch).- Parameters:
accepted- records to store
-
shutdown
Description copied from interface:LogExporterReleases resources. Called once byBatchProcessor.shutdown.- Specified by:
shutdownin interfaceLogExporter- Returns:
- completes when the exporter is closed
-
records
Accepted records in export order.- Returns:
- copy of the records
-
batchSizes
Sizes of all export calls.- Returns:
- batch sizes
-
gzipFlags
Gzip flags of all export calls.- Returns:
- flags
-
shutdownCount
public int shutdownCount()Number ofshutdown()calls.- Returns:
- count
-
reset
public void reset()Forgets stored records and statistics (scripted outcomes stay).
-