NVIDIA DeepStream SDK API Reference

9.2 Release
sdk::trace::BatchSpanProcessor Class Reference

Detailed Description

This is an implementation of the SpanProcessor which creates batches of finished spans and passes the export-friendly span data representations to the configured SpanExporter.

Definition at line 34 of file includes/opentelemetry/sdk/trace/batch_span_processor.h.

Inheritance diagram for sdk::trace::BatchSpanProcessor:
Collaboration diagram for sdk::trace::BatchSpanProcessor:

Data Structures

struct  SynchronizationData
 

Public Member Functions

 BatchSpanProcessor (std::unique_ptr< SpanExporter > &&exporter, const BatchSpanProcessorOptions &options)
 Creates a batch span processor by configuring the specified exporter and other parameters as per the official, language-agnostic opentelemetry specs. More...
 
 BatchSpanProcessor (std::unique_ptr< SpanExporter > &&exporter, const BatchSpanProcessorOptions &options, const BatchSpanProcessorRuntimeOptions &runtime_options)
 Creates a batch span processor by configuring the specified exporter and other parameters as per the official, language-agnostic opentelemetry specs. More...
 
std::unique_ptr< Recordable > MakeRecordable () noexcept override
 Requests a Recordable(Span) from the configured exporter. More...
 
void OnStart (Recordable &span, const opentelemetry::trace::SpanContext &parent_context) noexcept override
 Called when a span is started. More...
 
void OnEnd (std::unique_ptr< Recordable > &&span) noexcept override
 Called when a span ends. More...
 
bool ForceFlush (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept override
 Export all ended spans that have not been exported yet. More...
 
bool Shutdown (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept override
 Shuts down the processor and does any cleanup required. More...
 
 ~BatchSpanProcessor () override
 Class destructor which invokes the Shutdown() method. More...
 
 BatchSpanProcessor (std::unique_ptr< SpanExporter > &&exporter, const BatchSpanProcessorOptions &options)
 Creates a batch span processor by configuring the specified exporter and other parameters as per the official, language-agnostic opentelemetry specs. More...
 
 BatchSpanProcessor (std::unique_ptr< SpanExporter > &&exporter, const BatchSpanProcessorOptions &options, const BatchSpanProcessorRuntimeOptions &runtime_options)
 Creates a batch span processor by configuring the specified exporter and other parameters as per the official, language-agnostic opentelemetry specs. More...
 
std::unique_ptr< Recordable > MakeRecordable () noexcept override
 Requests a Recordable(Span) from the configured exporter. More...
 
void OnStart (Recordable &span, const opentelemetry::trace::SpanContext &parent_context) noexcept override
 Called when a span is started. More...
 
void OnEnd (std::unique_ptr< Recordable > &&span) noexcept override
 Called when a span ends. More...
 
bool ForceFlush (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept override
 Export all ended spans that have not been exported yet. More...
 
bool Shutdown (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept override
 Shuts down the processor and does any cleanup required. More...
 
 ~BatchSpanProcessor () override
 Class destructor which invokes the Shutdown() method. More...
 

Protected Member Functions

bool InternalShutdown (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept
 Shuts down the processor and does any cleanup required. More...
 
void DoBackgroundWork ()
 The background routine performed by the worker thread. More...
 
virtual void Export ()
 Exports all ended spans to the configured exporter. More...
 
void DrainQueue ()
 Called when Shutdown() is invoked. More...
 
void GetWaitAdjustedTime (std::chrono::microseconds &timeout, std::chrono::time_point< std::chrono::system_clock > &start_time)
 
bool InternalShutdown (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept
 Shuts down the processor and does any cleanup required. More...
 
void DoBackgroundWork ()
 The background routine performed by the worker thread. More...
 
virtual void Export ()
 Exports all ended spans to the configured exporter. More...
 
void DrainQueue ()
 Called when Shutdown() is invoked. More...
 
void GetWaitAdjustedTime (std::chrono::microseconds &timeout, std::chrono::time_point< std::chrono::system_clock > &start_time)
 

Static Protected Member Functions

static void NotifyCompletion (uint64_t notify_force_flush, const std::unique_ptr< SpanExporter > &exporter, const std::shared_ptr< SynchronizationData > &synchronization_data)
 Notify completion of shutdown and force flush. More...
 
static void NotifyCompletion (uint64_t notify_force_flush, const std::unique_ptr< SpanExporter > &exporter, const std::shared_ptr< SynchronizationData > &synchronization_data)
 Notify completion of shutdown and force flush. More...
 

Protected Attributes

std::unique_ptr< SpanExporter > exporter_
 
const size_t max_queue_size_
 
const std::chrono::milliseconds schedule_delay_millis_
 
const size_t max_export_batch_size_
 
opentelemetry::sdk::common::CircularBuffer< Recordable > buffer_
 
std::shared_ptr< SynchronizationData > synchronization_data_
 
std::shared_ptr< sdk::common::ThreadInstrumentation > worker_thread_instrumentation_
 
std::thread worker_thread_
 

Constructor & Destructor Documentation

◆ BatchSpanProcessor() [1/4]

sdk::trace::BatchSpanProcessor::BatchSpanProcessor ( std::unique_ptr< SpanExporter > &&  exporter,
const BatchSpanProcessorOptions &  options 
)

Creates a batch span processor by configuring the specified exporter and other parameters as per the official, language-agnostic opentelemetry specs.

Parameters
exporterThe backend exporter to pass the ended spans to.
optionsThe batch SpanProcessor configuration options.

◆ BatchSpanProcessor() [2/4]

sdk::trace::BatchSpanProcessor::BatchSpanProcessor ( std::unique_ptr< SpanExporter > &&  exporter,
const BatchSpanProcessorOptions &  options,
const BatchSpanProcessorRuntimeOptions &  runtime_options 
)

Creates a batch span processor by configuring the specified exporter and other parameters as per the official, language-agnostic opentelemetry specs.

Parameters
exporterThe backend exporter to pass the ended spans to.
optionsThe batch SpanProcessor configuration options.
runtime_optionsThe batch SpanProcessor runtime options.

◆ ~BatchSpanProcessor() [1/2]

sdk::trace::BatchSpanProcessor::~BatchSpanProcessor ( )
override

Class destructor which invokes the Shutdown() method.

The Shutdown() method is supposed to be invoked when the Tracer is shutdown (as per other languages), but the C++ Tracer only takes shared ownership of the processor, and thus doesn't call Shutdown (as the processor might be shared with other Tracers).

◆ BatchSpanProcessor() [3/4]

sdk::trace::BatchSpanProcessor::BatchSpanProcessor ( std::unique_ptr< SpanExporter > &&  exporter,
const BatchSpanProcessorOptions &  options 
)

Creates a batch span processor by configuring the specified exporter and other parameters as per the official, language-agnostic opentelemetry specs.

Parameters
exporterThe backend exporter to pass the ended spans to.
optionsThe batch SpanProcessor configuration options.

◆ BatchSpanProcessor() [4/4]

sdk::trace::BatchSpanProcessor::BatchSpanProcessor ( std::unique_ptr< SpanExporter > &&  exporter,
const BatchSpanProcessorOptions &  options,
const BatchSpanProcessorRuntimeOptions &  runtime_options 
)

Creates a batch span processor by configuring the specified exporter and other parameters as per the official, language-agnostic opentelemetry specs.

Parameters
exporterThe backend exporter to pass the ended spans to.
optionsThe batch SpanProcessor configuration options.
runtime_optionsThe batch SpanProcessor runtime options.

◆ ~BatchSpanProcessor() [2/2]

sdk::trace::BatchSpanProcessor::~BatchSpanProcessor ( )
override

Class destructor which invokes the Shutdown() method.

The Shutdown() method is supposed to be invoked when the Tracer is shutdown (as per other languages), but the C++ Tracer only takes shared ownership of the processor, and thus doesn't call Shutdown (as the processor might be shared with other Tracers).

Member Function Documentation

◆ DoBackgroundWork() [1/2]

void sdk::trace::BatchSpanProcessor::DoBackgroundWork ( )
protected

The background routine performed by the worker thread.

◆ DoBackgroundWork() [2/2]

void sdk::trace::BatchSpanProcessor::DoBackgroundWork ( )
protected

The background routine performed by the worker thread.

◆ DrainQueue() [1/2]

void sdk::trace::BatchSpanProcessor::DrainQueue ( )
protected

Called when Shutdown() is invoked.

Completely drains the queue of all its ended spans and passes them to the exporter.

◆ DrainQueue() [2/2]

void sdk::trace::BatchSpanProcessor::DrainQueue ( )
protected

Called when Shutdown() is invoked.

Completely drains the queue of all its ended spans and passes them to the exporter.

◆ Export() [1/2]

virtual void sdk::trace::BatchSpanProcessor::Export ( )
protectedvirtual

Exports all ended spans to the configured exporter.

◆ Export() [2/2]

virtual void sdk::trace::BatchSpanProcessor::Export ( )
protectedvirtual

Exports all ended spans to the configured exporter.

◆ ForceFlush() [1/2]

bool sdk::trace::BatchSpanProcessor::ForceFlush ( std::chrono::microseconds  timeout = (std::chrono::microseconds::max)())
overridevirtualnoexcept

Export all ended spans that have not been exported yet.

NOTE: Timeout functionality not supported yet.

Implements sdk::trace::SpanProcessor.

◆ ForceFlush() [2/2]

bool sdk::trace::BatchSpanProcessor::ForceFlush ( std::chrono::microseconds  timeout = (std::chrono::microseconds::max)())
overridevirtualnoexcept

Export all ended spans that have not been exported yet.

NOTE: Timeout functionality not supported yet.

Implements sdk::trace::SpanProcessor.

◆ GetWaitAdjustedTime() [1/2]

void sdk::trace::BatchSpanProcessor::GetWaitAdjustedTime ( std::chrono::microseconds &  timeout,
std::chrono::time_point< std::chrono::system_clock > &  start_time 
)
protected

◆ GetWaitAdjustedTime() [2/2]

void sdk::trace::BatchSpanProcessor::GetWaitAdjustedTime ( std::chrono::microseconds &  timeout,
std::chrono::time_point< std::chrono::system_clock > &  start_time 
)
protected

◆ InternalShutdown() [1/2]

bool sdk::trace::BatchSpanProcessor::InternalShutdown ( std::chrono::microseconds  timeout = (std::chrono::microseconds::max)())
protectednoexcept

Shuts down the processor and does any cleanup required.

Completely drains the buffer/queue of all its ended spans and passes them to the exporter.

Parameters
timeoutminimum amount of microseconds to wait for shutdown before giving up and returning failure.
Returns
true if the shutdown succeeded, false otherwise

◆ InternalShutdown() [2/2]

bool sdk::trace::BatchSpanProcessor::InternalShutdown ( std::chrono::microseconds  timeout = (std::chrono::microseconds::max)())
protectednoexcept

Shuts down the processor and does any cleanup required.

Completely drains the buffer/queue of all its ended spans and passes them to the exporter.

Parameters
timeoutminimum amount of microseconds to wait for shutdown before giving up and returning failure.
Returns
true if the shutdown succeeded, false otherwise

◆ MakeRecordable() [1/2]

std::unique_ptr<Recordable> sdk::trace::BatchSpanProcessor::MakeRecordable ( )
overridevirtualnoexcept

Requests a Recordable(Span) from the configured exporter.

Returns
A recordable generated by the backend exporter

Implements sdk::trace::SpanProcessor.

◆ MakeRecordable() [2/2]

std::unique_ptr<Recordable> sdk::trace::BatchSpanProcessor::MakeRecordable ( )
overridevirtualnoexcept

Requests a Recordable(Span) from the configured exporter.

Returns
A recordable generated by the backend exporter

Implements sdk::trace::SpanProcessor.

◆ NotifyCompletion() [1/2]

static void sdk::trace::BatchSpanProcessor::NotifyCompletion ( uint64_t  notify_force_flush,
const std::unique_ptr< SpanExporter > &  exporter,
const std::shared_ptr< SynchronizationData > &  synchronization_data 
)
staticprotected

Notify completion of shutdown and force flush.

This may be called from the any thread at any time

Parameters
notify_force_flushSequence to indicate whether to notify force flush completion.
synchronization_dataSynchronization data to be notified.

◆ NotifyCompletion() [2/2]

static void sdk::trace::BatchSpanProcessor::NotifyCompletion ( uint64_t  notify_force_flush,
const std::unique_ptr< SpanExporter > &  exporter,
const std::shared_ptr< SynchronizationData > &  synchronization_data 
)
staticprotected

Notify completion of shutdown and force flush.

This may be called from the any thread at any time

Parameters
notify_force_flushSequence to indicate whether to notify force flush completion.
synchronization_dataSynchronization data to be notified.

◆ OnEnd() [1/2]

void sdk::trace::BatchSpanProcessor::OnEnd ( std::unique_ptr< Recordable > &&  span)
overridevirtualnoexcept

Called when a span ends.

Parameters
span- A recordable for a span that just ended

Implements sdk::trace::SpanProcessor.

◆ OnEnd() [2/2]

void sdk::trace::BatchSpanProcessor::OnEnd ( std::unique_ptr< Recordable > &&  span)
overridevirtualnoexcept

Called when a span ends.

Parameters
span- A recordable for a span that just ended

Implements sdk::trace::SpanProcessor.

◆ OnStart() [1/2]

void sdk::trace::BatchSpanProcessor::OnStart ( Recordable &  span,
const opentelemetry::trace::SpanContext &  parent_context 
)
overridevirtualnoexcept

Called when a span is started.

NOTE: This method is a no-op.

Parameters
span- The span that just started
parent_context- The parent context of the span that just started

Implements sdk::trace::SpanProcessor.

◆ OnStart() [2/2]

void sdk::trace::BatchSpanProcessor::OnStart ( Recordable &  span,
const opentelemetry::trace::SpanContext &  parent_context 
)
overridevirtualnoexcept

Called when a span is started.

NOTE: This method is a no-op.

Parameters
span- The span that just started
parent_context- The parent context of the span that just started

Implements sdk::trace::SpanProcessor.

◆ Shutdown() [1/2]

bool sdk::trace::BatchSpanProcessor::Shutdown ( std::chrono::microseconds  timeout = (std::chrono::microseconds::max)())
overridevirtualnoexcept

Shuts down the processor and does any cleanup required.

Completely drains the buffer/queue of all its ended spans and passes them to the exporter.

Parameters
timeoutminimum amount of microseconds to wait for shutdown before giving up and returning failure.
Returns
true if the shutdown succeeded, false otherwise

Implements sdk::trace::SpanProcessor.

◆ Shutdown() [2/2]

bool sdk::trace::BatchSpanProcessor::Shutdown ( std::chrono::microseconds  timeout = (std::chrono::microseconds::max)())
overridevirtualnoexcept

Shuts down the processor and does any cleanup required.

Completely drains the buffer/queue of all its ended spans and passes them to the exporter.

Parameters
timeoutminimum amount of microseconds to wait for shutdown before giving up and returning failure.
Returns
true if the shutdown succeeded, false otherwise

Implements sdk::trace::SpanProcessor.

Field Documentation

◆ buffer_

opentelemetry::sdk::common::CircularBuffer< Recordable > sdk::trace::BatchSpanProcessor::buffer_
protected

◆ exporter_

std::unique_ptr< SpanExporter > sdk::trace::BatchSpanProcessor::exporter_
protected

◆ max_export_batch_size_

const size_t sdk::trace::BatchSpanProcessor::max_export_batch_size_
protected

◆ max_queue_size_

const size_t sdk::trace::BatchSpanProcessor::max_queue_size_
protected

◆ schedule_delay_millis_

const std::chrono::milliseconds sdk::trace::BatchSpanProcessor::schedule_delay_millis_
protected

◆ synchronization_data_

std::shared_ptr< SynchronizationData > sdk::trace::BatchSpanProcessor::synchronization_data_
protected

◆ worker_thread_

std::thread sdk::trace::BatchSpanProcessor::worker_thread_
protected

◆ worker_thread_instrumentation_

std::shared_ptr< sdk::common::ThreadInstrumentation > sdk::trace::BatchSpanProcessor::worker_thread_instrumentation_
protected

The documentation for this class was generated from the following file: