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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final AtomicBoolean
private static final Logger
private static final AttributeKey
<Boolean> private static final AttributeKey
<String> private static final String
private final BatchSpanProcessor.Worker
private static final String
-
Constructor Summary
ConstructorsConstructorDescriptionBatchSpanProcessor
(SpanExporter spanExporter, boolean exportUnsampledSpans, MeterProvider meterProvider, long scheduleDelayNanos, int maxQueueSize, int maxExportBatchSize, long exporterTimeoutNanos) -
Method Summary
Modifier and TypeMethodDescriptionstatic BatchSpanProcessorBuilder
builder
(SpanExporter spanExporter) Returns a new Builder forBatchSpanProcessor
.Processes all span events that have not yet been processed.getBatch()
(package private) Queue
<ReadableSpan> getQueue()
Return the processor's configuredSpanExporter
.boolean
Returnstrue
if thisSpanProcessor
requires end events.boolean
Returnstrue
if thisSpanProcessor
requires start events.void
onEnd
(ReadableSpan span) Called when aSpan
is ended, if theSpan.isRecording()
returns true.void
onStart
(Context parentContext, ReadWriteSpan span) Called when aSpan
is started, if theSpan.isRecording()
returns true.shutdown()
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, wait
Methods inherited from interface io.opentelemetry.sdk.trace.SpanProcessor
close
-
Field Details
-
logger
-
WORKER_THREAD_NAME
-
SPAN_PROCESSOR_TYPE_LABEL
-
SPAN_PROCESSOR_DROPPED_LABEL
-
SPAN_PROCESSOR_TYPE_VALUE
-
exportUnsampledSpans
private final boolean exportUnsampledSpans -
worker
-
isShutdown
-
-
Constructor Details
-
BatchSpanProcessor
BatchSpanProcessor(SpanExporter spanExporter, boolean exportUnsampledSpans, MeterProvider meterProvider, long scheduleDelayNanos, int maxQueueSize, int maxExportBatchSize, long exporterTimeoutNanos)
-
-
Method Details
-
builder
Returns a new Builder forBatchSpanProcessor
.- Parameters:
spanExporter
- theSpanExporter
to which the Spans are pushed.- Returns:
- a new
BatchSpanProcessorBuilder
. - Throws:
NullPointerException
- if thespanExporter
isnull
.
-
onStart
Description copied from interface:SpanProcessor
Called when aSpan
is 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:
onStart
in interfaceSpanProcessor
- Parameters:
parentContext
- the parentContext
of the span that just started.span
- theSpan
that just started.
-
isStartRequired
public boolean isStartRequired()Description copied from interface:SpanProcessor
Returnstrue
if thisSpanProcessor
requires start events.- Specified by:
isStartRequired
in interfaceSpanProcessor
- Returns:
true
if thisSpanProcessor
requires start events.
-
onEnd
Description copied from interface:SpanProcessor
Called when aSpan
is 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:
onEnd
in interfaceSpanProcessor
- Parameters:
span
- theSpan
that just ended.
-
isEndRequired
public boolean isEndRequired()Description copied from interface:SpanProcessor
Returnstrue
if thisSpanProcessor
requires end events.- Specified by:
isEndRequired
in interfaceSpanProcessor
- Returns:
true
if thisSpanProcessor
requires end events.
-
shutdown
Description copied from interface:SpanProcessor
Processes all span events that have not yet been processed and closes used resources.- Specified by:
shutdown
in interfaceSpanProcessor
- Returns:
- a
CompletableResultCode
which completes when shutdown is finished.
-
forceFlush
Description copied from interface:SpanProcessor
Processes all span events that have not yet been processed.- Specified by:
forceFlush
in interfaceSpanProcessor
- Returns:
- a
CompletableResultCode
which completes when currently queued spans are finished processing.
-
getSpanExporter
Return the processor's configuredSpanExporter
.- Since:
- 1.37.0
-
getBatch
-
getQueue
Queue<ReadableSpan> getQueue() -
toString
-