Package io.opentelemetry.sdk.logs.export
Class BatchLogRecordProcessor
java.lang.Object
io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor
- All Implemented Interfaces:
LogRecordProcessor
,Closeable
,AutoCloseable
Implementation of the
LogRecordProcessor
that batches logs exported by the SDK then
pushes them to the exporter pipeline.
All logs reported by the SDK implementation are first added to a synchronized queue (with a
maxQueueSize
maximum size, if queue is full logs are dropped). Logs are exported either
when there are maxExportBatchSize
pending logs or scheduleDelayNanos
has passed
since the last export finished.
- Since:
- 1.27.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBoolean
private static final AttributeKey
<Boolean> private static final AttributeKey
<String> private static final String
private final BatchLogRecordProcessor.Worker
private static final String
-
Constructor Summary
ConstructorsConstructorDescriptionBatchLogRecordProcessor
(LogRecordExporter logRecordExporter, MeterProvider meterProvider, long scheduleDelayNanos, int maxQueueSize, int maxExportBatchSize, long exporterTimeoutNanos) -
Method Summary
Modifier and TypeMethodDescriptionbuilder
(LogRecordExporter logRecordExporter) Returns a new Builder forBatchLogRecordProcessor
.Process all log records that have not yet been processed.(package private) List
<LogRecordData> getBatch()
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
-
WORKER_THREAD_NAME
-
LOG_RECORD_PROCESSOR_TYPE_LABEL
-
LOG_RECORD_PROCESSOR_DROPPED_LABEL
-
LOG_RECORD_PROCESSOR_TYPE_VALUE
-
worker
-
isShutdown
-
-
Constructor Details
-
BatchLogRecordProcessor
BatchLogRecordProcessor(LogRecordExporter logRecordExporter, MeterProvider meterProvider, long scheduleDelayNanos, int maxQueueSize, int maxExportBatchSize, long exporterTimeoutNanos)
-
-
Method Details
-
builder
Returns a new Builder forBatchLogRecordProcessor
.- Parameters:
logRecordExporter
- theLogRecordExporter
to which the Logs are pushed- Returns:
- a new
BatchLogRecordProcessor
. - Throws:
NullPointerException
- if thelogRecordExporter
isnull
.
-
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
-
getBatch
List<LogRecordData> getBatch() -
toString
-