Class SimpleLogRecordProcessor
- java.lang.Object
-
- io.opentelemetry.sdk.logs.export.SimpleLogRecordProcessor
-
- All Implemented Interfaces:
LogRecordProcessor,java.io.Closeable,java.lang.AutoCloseable
public final class SimpleLogRecordProcessor extends java.lang.Object implements LogRecordProcessor
An implementation of theLogRecordProcessorthat passesLogRecordDatadirectly 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
BatchLogRecordProcessorinstead, including in special environments such as serverless runtimes.SimpleLogRecordProcessoris generally meant to for testing only.- Since:
- 1.27.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBooleanisShutdownprivate static java.util.logging.Loggerloggerprivate LogRecordExporterlogRecordExporterprivate java.util.Set<CompletableResultCode>pendingExports
-
Constructor Summary
Constructors Modifier Constructor Description privateSimpleLogRecordProcessor(LogRecordExporter logRecordExporter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LogRecordProcessorcreate(LogRecordExporter exporter)Returns a newSimpleLogRecordProcessorwhich exports logs to theLogRecordExportersynchronously.CompletableResultCodeforceFlush()Process all log records that have not yet been processed.LogRecordExportergetLogRecordExporter()Return the processor's configuredLogRecordExporter.voidonEmit(Context context, ReadWriteLogRecord logRecord)Called when aLoggerLogRecordBuilder.emit()s a log record.CompletableResultCodeshutdown()Shutdown the log processor.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.opentelemetry.sdk.logs.LogRecordProcessor
close
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
logRecordExporter
private final LogRecordExporter logRecordExporter
-
pendingExports
private final java.util.Set<CompletableResultCode> pendingExports
-
isShutdown
private final java.util.concurrent.atomic.AtomicBoolean isShutdown
-
-
Constructor Detail
-
SimpleLogRecordProcessor
private SimpleLogRecordProcessor(LogRecordExporter logRecordExporter)
-
-
Method Detail
-
create
public static LogRecordProcessor create(LogRecordExporter exporter)
Returns a newSimpleLogRecordProcessorwhich exports logs to theLogRecordExportersynchronously.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
BatchLogRecordProcessorinstead, including in special environments such as serverless runtimes.SimpleLogRecordProcessoris generally meant to for testing only.
-
onEmit
public void onEmit(Context context, ReadWriteLogRecord logRecord)
Description copied from interface:LogRecordProcessorCalled when aLoggerLogRecordBuilder.emit()s a log record.- Specified by:
onEmitin interfaceLogRecordProcessor- Parameters:
context- the context set viaLogRecordBuilder.setContext(Context), orContext.current()if not explicitly setlogRecord- the log record
-
shutdown
public CompletableResultCode shutdown()
Description copied from interface:LogRecordProcessorShutdown the log processor.- Specified by:
shutdownin interfaceLogRecordProcessor- Returns:
- result
-
forceFlush
public CompletableResultCode forceFlush()
Description copied from interface:LogRecordProcessorProcess all log records that have not yet been processed.- Specified by:
forceFlushin interfaceLogRecordProcessor- Returns:
- result
-
getLogRecordExporter
public LogRecordExporter getLogRecordExporter()
Return the processor's configuredLogRecordExporter.- Since:
- 1.37.0
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-