Class: OpenTelemetry::SDK::Trace::Export::MultiSpanExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb

Overview

Implementation of the SpanExporter duck type that simply forwards all received spans to a collection of SpanExporters.

Can be used to export to multiple backends using the same SpanProcessor like a SimpleSpanProcessor or a BatchSpanProcessor.

Instance Method Summary collapse

Constructor Details

#initialize(span_exporters) ⇒ MultiSpanExporter

Returns a new instance of MultiSpanExporter.



18
19
20
# File 'lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb', line 18

def initialize(span_exporters)
  @span_exporters = span_exporters.clone.freeze
end

Instance Method Details

#export(spans) ⇒ Integer

Called to export sampled Spans.

Parameters:

  • spans (Enumerable<Span>)

    the list of sampled Spans to be exported.

Returns:

  • (Integer)

    the result of the export.



27
28
29
30
31
32
33
34
35
36
# File 'lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb', line 27

def export(spans)
  @span_exporters.inject(SUCCESS) do |result_code, span_exporter|
    begin
      merge_result_code(result_code, span_exporter.export(spans))
    rescue => e # rubocop:disable Style/RescueStandardError
      OpenTelemetry.logger.warn("exception raised by export - #{e}")
      FAILED_NOT_RETRYABLE
    end
  end
end

#shutdownObject

Called when TracerFactory#shutdown is called, if this exporter is registered to a TracerFactory object.



40
41
42
# File 'lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb', line 40

def shutdown
  @span_exporters.each(&:shutdown)
end