Class InMemoryLogRecordExporter

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

public final class InMemoryLogRecordExporter extends Object implements io.opentelemetry.sdk.logs.export.LogRecordExporter
A LogRecordExporter implementation that can be used to test OpenTelemetry integration.
Since:
1.27.0
  • Method Details

    • create

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

      public List<io.opentelemetry.sdk.logs.data.LogRecordData> getFinishedLogRecordItems()
      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<io.opentelemetry.sdk.logs.data.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 io.opentelemetry.sdk.logs.export.LogRecordExporter
    • flush

      public io.opentelemetry.sdk.common.CompletableResultCode flush()
      Specified by:
      flush in interface io.opentelemetry.sdk.logs.export.LogRecordExporter
    • 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 io.opentelemetry.sdk.logs.export.LogRecordExporter