Class SimpleLogRecordProcessor
- All Implemented Interfaces:
LogRecordProcessor
,Closeable
,AutoCloseable
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBoolean
private static final Logger
private final LogRecordExporter
private final Set
<CompletableResultCode> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
SimpleLogRecordProcessor
(LogRecordExporter logRecordExporter) -
Method Summary
Modifier and TypeMethodDescriptionstatic LogRecordProcessor
create
(LogRecordExporter exporter) Returns a newSimpleLogRecordProcessor
which exports logs to theLogRecordExporter
synchronously.Process all log records that have not yet been processed.Return the processor's configuredLogRecordExporter
.void
onEmit
(Context context, ReadWriteLogRecord logRecord) Called when aLogger
LogRecordBuilder.emit()
s a log record.shutdown()
Shutdown the log processor.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 Details
-
logger
-
logRecordExporter
-
pendingExports
-
isShutdown
-
-
Constructor Details
-
SimpleLogRecordProcessor
-
-
Method Details
-
create
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
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
Description copied from interface:LogRecordProcessor
Shutdown the log processor.- Specified by:
shutdown
in interfaceLogRecordProcessor
- Returns:
- result
-
forceFlush
Description copied from interface:LogRecordProcessor
Process all log records that have not yet been processed.- Specified by:
forceFlush
in interfaceLogRecordProcessor
- Returns:
- result
-
getLogRecordExporter
Return the processor's configuredLogRecordExporter
.- Since:
- 1.37.0
-
toString
-