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
# File 'lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb', line 27

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

#shutdownInteger

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

Returns:

  • (Integer)

    SUCCESS if no error occurred, FAILURE if a non-specific failure occurred, TIMEOUT if a timeout occurred.



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

def shutdown
  @span_exporters.map(&:shutdown).uniq.max
end