Class: OpenTelemetry::SDK::Trace::Export::MultiSpanExporter
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Trace::Export::MultiSpanExporter
- 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
-
#export(spans, timeout: nil) ⇒ Integer
Called to export sampled Spans.
-
#initialize(span_exporters) ⇒ MultiSpanExporter
constructor
A new instance of MultiSpanExporter.
-
#shutdown(timeout: nil) ⇒ Integer
Called when TracerProvider#shutdown is called, if this exporter is registered to a TracerProvider object.
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, timeout: nil) ⇒ Integer
Called to export sampled Spans.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb', line 28 def export(spans, timeout: nil) start_time = Time.now results = @span_exporters.map do |span_exporter| span_exporter.export(spans, timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)) rescue => e # rubocop:disable Style/RescueStandardError OpenTelemetry.logger.warn("exception raised by export - #{e}") FAILURE end results.uniq.max || SUCCESS end |
#shutdown(timeout: nil) ⇒ Integer
Called when TracerProvider#shutdown is called, if this exporter is registered to a TracerProvider object.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb', line 45 def shutdown(timeout: nil) start_time = Time.now results = @span_exporters.map do |processor| remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time) return TIMEOUT if remaining_timeout&.zero? processor.shutdown(timeout: remaining_timeout) end results.uniq.max || SUCCESS end |