Class InMemoryLogExporter

java.lang.Object
io.opentelemetry.sdk.logs.export.InMemoryLogExporter
All Implemented Interfaces:
LogExporter

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

    • create

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

      public List<LogData> 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<LogData> 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 LogExporter
      Parameters:
      logs - the collection of LogData 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: LogExporter
      Exports the collection of LogData that have not yet been exported.
      Specified by:
      flush in interface LogExporter
      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 LogExporter, will return CompletableResultCode.ofFailure()

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