Class BatchSpanProcessor
java.lang.Object
io.opentelemetry.sdk.trace.export.BatchSpanProcessor
- All Implemented Interfaces:
SpanProcessor,Closeable,AutoCloseable
Implementation of the
SpanProcessor that batches spans exported by the SDK then pushes
them to the exporter pipeline.
All spans reported by the SDK implementation are first added to a synchronized queue (with a
maxQueueSize maximum size, if queue is full spans are dropped). Spans are exported either
when there are maxExportBatchSize pending spans or scheduleDelayNanos has passed
since the last export finished.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BatchSpanProcessorBuilderbuilder(SpanExporter spanExporter) Returns a new Builder forBatchSpanProcessor.io.opentelemetry.sdk.common.CompletableResultCodeProcesses all span events that have not yet been processed.Return the processor's configuredSpanExporter.booleanReturnstrueif thisSpanProcessorrequires end events.booleanReturnstrueif thisSpanProcessorrequires start events.voidonEnd(ReadableSpan span) Called when aSpanis ended, if theSpan.isRecording()returns true.voidonStart(io.opentelemetry.context.Context parentContext, ReadWriteSpan span) Called when aSpanis started, if theSpan.isRecording()returns true.io.opentelemetry.sdk.common.CompletableResultCodeshutdown()Processes all span events that have not yet been processed and closes used resources.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.opentelemetry.sdk.trace.SpanProcessor
close
-
Method Details
-
builder
Returns a new Builder forBatchSpanProcessor.- Parameters:
spanExporter- theSpanExporterto which the Spans are pushed.- Returns:
- a new
BatchSpanProcessorBuilder. - Throws:
NullPointerException- if thespanExporterisnull.
-
onStart
Description copied from interface:SpanProcessorCalled when aSpanis started, if theSpan.isRecording()returns true.This method is called synchronously on the execution thread, should not throw or block the execution thread.
- Specified by:
onStartin interfaceSpanProcessor- Parameters:
parentContext- the parentContextof the span that just started.span- theSpanthat just started.
-
isStartRequired
public boolean isStartRequired()Description copied from interface:SpanProcessorReturnstrueif thisSpanProcessorrequires start events.- Specified by:
isStartRequiredin interfaceSpanProcessor- Returns:
trueif thisSpanProcessorrequires start events.
-
onEnd
Description copied from interface:SpanProcessorCalled when aSpanis ended, if theSpan.isRecording()returns true.This method is called synchronously on the execution thread, should not throw or block the execution thread.
- Specified by:
onEndin interfaceSpanProcessor- Parameters:
span- theSpanthat just ended.
-
isEndRequired
public boolean isEndRequired()Description copied from interface:SpanProcessorReturnstrueif thisSpanProcessorrequires end events.- Specified by:
isEndRequiredin interfaceSpanProcessor- Returns:
trueif thisSpanProcessorrequires end events.
-
shutdown
public io.opentelemetry.sdk.common.CompletableResultCode shutdown()Description copied from interface:SpanProcessorProcesses all span events that have not yet been processed and closes used resources.- Specified by:
shutdownin interfaceSpanProcessor- Returns:
- a
CompletableResultCodewhich completes when shutdown is finished.
-
forceFlush
public io.opentelemetry.sdk.common.CompletableResultCode forceFlush()Description copied from interface:SpanProcessorProcesses all span events that have not yet been processed.- Specified by:
forceFlushin interfaceSpanProcessor- Returns:
- a
CompletableResultCodewhich completes when currently queued spans are finished processing.
-
getSpanExporter
Return the processor's configuredSpanExporter.- Since:
- 1.37.0
-
toString
-