Class SimpleLogRecordProcessor

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

public final class SimpleLogRecordProcessor extends Object implements LogRecordProcessor
An implementation of the LogRecordProcessor that passes LogRecordData directly to the configured exporter.

This processor will cause all logs to be exported directly as they finish, meaning each export request will have a single log. Most backends will not perform well with a single log per request so unless you know what you're doing, strongly consider using BatchLogRecordProcessor instead, including in special environments such as serverless runtimes. SimpleLogRecordProcessor is generally meant to for testing only.

Since:
1.27.0
  • Method Details

    • create

      public static LogRecordProcessor create(LogRecordExporter exporter)
      Returns a new SimpleLogRecordProcessor which exports logs to the LogRecordExporter synchronously.

      This processor will cause all logs to be exported directly as they finish, meaning each export request will have a single log. Most backends will not perform well with a single log per request so unless you know what you're doing, strongly consider using BatchLogRecordProcessor instead, including in special environments such as serverless runtimes. SimpleLogRecordProcessor is generally meant to for testing only.

    • onEmit

      public void onEmit(io.opentelemetry.context.Context context, ReadWriteLogRecord logRecord)
      Description copied from interface: LogRecordProcessor
      Called when a Logger LogRecordBuilder.emit()s a log record.
      Specified by:
      onEmit in interface LogRecordProcessor
      Parameters:
      context - the context set via LogRecordBuilder.setContext(Context), or Context.current() if not explicitly set
      logRecord - the log record
    • shutdown

      public io.opentelemetry.sdk.common.CompletableResultCode shutdown()
      Description copied from interface: LogRecordProcessor
      Shutdown the log processor.
      Specified by:
      shutdown in interface LogRecordProcessor
      Returns:
      result
    • forceFlush

      public io.opentelemetry.sdk.common.CompletableResultCode forceFlush()
      Description copied from interface: LogRecordProcessor
      Process all log records that have not yet been processed.
      Specified by:
      forceFlush in interface LogRecordProcessor
      Returns:
      result
    • getLogRecordExporter

      public LogRecordExporter getLogRecordExporter()
      Return the processor's configured LogRecordExporter.
      Since:
      1.37.0
    • toString

      public String toString()
      Overrides:
      toString in class Object