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 theLogRecordProcessor
that passesLogRecordData
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
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBoolean
isShutdown
private static java.util.logging.Logger
logger
private LogRecordExporter
logRecordExporter
private java.util.Set<CompletableResultCode>
pendingExports
-
Constructor Summary
Constructors Modifier Constructor Description private
SimpleLogRecordProcessor(LogRecordExporter logRecordExporter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LogRecordProcessor
create(LogRecordExporter exporter)
Returns a newSimpleLogRecordProcessor
which exports logs to theLogRecordExporter
synchronously.CompletableResultCode
forceFlush()
Process all log records that have not yet been processed.LogRecordExporter
getLogRecordExporter()
Return the processor's configuredLogRecordExporter
.void
onEmit(Context context, ReadWriteLogRecord logRecord)
Called when aLogger
LogRecordBuilder.emit()
s a log record.CompletableResultCode
shutdown()
Shutdown the log processor.java.lang.String
toString()
-
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 newSimpleLogRecordProcessor
which exports logs to theLogRecordExporter
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(Context context, ReadWriteLogRecord logRecord)
Description copied from interface:LogRecordProcessor
Called when aLogger
LogRecordBuilder.emit()
s a log record.- Specified by:
onEmit
in 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:LogRecordProcessor
Shutdown the log processor.- Specified by:
shutdown
in interfaceLogRecordProcessor
- Returns:
- result
-
forceFlush
public CompletableResultCode forceFlush()
Description copied from interface:LogRecordProcessor
Process all log records that have not yet been processed.- Specified by:
forceFlush
in interfaceLogRecordProcessor
- Returns:
- result
-
getLogRecordExporter
public LogRecordExporter getLogRecordExporter()
Return the processor's configuredLogRecordExporter
.- Since:
- 1.37.0
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-