Class InMemoryLogRecordExporter

java.lang.Object
io.opentelemetry.sdk.logs.export.InMemoryLogRecordExporter
All Implemented Interfaces:
LogRecordExporter, Closeable, AutoCloseable

public final class InMemoryLogRecordExporter extends Object implements LogRecordExporter
A LogRecordExporter implementation that can be used to test OpenTelemetry integration.
  • Method Details

    • create

      public static InMemoryLogRecordExporter create()
      Returns a new instance of the InMemoryLogRecordExporter.
      Returns:
      a new instance of the InMemoryLogRecordExporter.
    • getFinishedLogItems

      public List<LogRecordData> getFinishedLogItems()
      Returns a List of the finished Logs, represented by LogRecord.
      Returns:
      a List of the finished Logs.
    • reset

      public void reset()
      Clears the internal List of finished Logs.

      Does not reset the state of this exporter if already shutdown.

    • export

      public io.opentelemetry.sdk.common.CompletableResultCode export(Collection<LogRecordData> logs)
      Exports the collection of Logs into the inmemory queue.

      If this is called after shutdown, this will return ResultCode.FAILURE.

      Specified by:
      export in interface LogRecordExporter
      Parameters:
      logs - the collection of LogRecordData to be exported
      Returns:
      the result of the export, which is often an asynchronous operation
    • flush

      public io.opentelemetry.sdk.common.CompletableResultCode flush()
      Description copied from interface: LogRecordExporter
      Exports the collection of LogRecordData that have not yet been exported.
      Specified by:
      flush in interface LogRecordExporter
      Returns:
      the result of the flush, which is often an asynchronous operation
    • shutdown

      public io.opentelemetry.sdk.common.CompletableResultCode shutdown()
      Clears the internal List of finished Logs.

      Any subsequent call to export() function on this exporter, will return CompletableResultCode.ofFailure()

      Specified by:
      shutdown in interface LogRecordExporter
      Returns:
      a CompletableResultCode which is completed when shutdown completes