Class BatchSpanProcessor

Inheritance Relationships

Base Type

Class Documentation

class opentelemetry::sdk::trace::BatchSpanProcessor : public opentelemetry::sdk::trace::SpanProcessor

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.

Public 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.

Parameters
  • exporter – - The backend exporter to pass the ended spans to.

  • options – - The batch SpanProcessor options.

virtual std::unique_ptr<Recordable> MakeRecordable() noexcept override

Requests a Recordable(Span) from the configured exporter.

Returns

A recordable generated by the backend exporter

virtual void OnStart(Recordable &span, const opentelemetry::trace::SpanContext &parent_context) noexcept override

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

virtual void OnEnd(std::unique_ptr<Recordable> &&span) noexcept override

Called when a span ends.

Parameters

span – - A recordable for a span that just ended

virtual bool ForceFlush(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override

Export all ended spans that have not been exported yet.

NOTE: Timeout functionality not supported yet.

virtual bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override

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. Any subsequent calls to OnStart, OnEnd, ForceFlush or Shutdown will return immediately without doing anything.

NOTE: Timeout functionality not supported yet.

~BatchSpanProcessor()

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).