Class: OpenTelemetry::SDK::Trace::MultiSpanProcessor
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Trace::MultiSpanProcessor
- Defined in:
- lib/opentelemetry/sdk/trace/multi_span_processor.rb
Overview
Implementation of the SpanProcessor duck type that simply forwards all received events to a list of SpanProcessors.
Instance Method Summary collapse
-
#force_flush(timeout: nil) ⇒ Integer
Export all ended spans to the configured
Exporter
that have not yet been exported. -
#initialize(span_processors) ⇒ MultiSpanProcessor
constructor
Creates a new MultiSpanProcessor.
-
#on_finish(span) ⇒ Object
Called when a Span is ended, if the Span#recording? returns true.
-
#on_start(span, parent_context) ⇒ Object
Called when a Span is started, if the Span#recording? returns true.
-
#shutdown(timeout: nil) ⇒ Integer
Called when TracerProvider#shutdown is called.
Constructor Details
#initialize(span_processors) ⇒ MultiSpanProcessor
Creates a new OpenTelemetry::SDK::Trace::MultiSpanProcessor.
18 19 20 |
# File 'lib/opentelemetry/sdk/trace/multi_span_processor.rb', line 18 def initialize(span_processors) @span_processors = span_processors.to_a.freeze end |
Instance Method Details
#force_flush(timeout: nil) ⇒ Integer
Export all ended spans to the configured Exporter
that have not yet been exported.
This method should only be called in cases where it is absolutely necessary, such as when using some FaaS providers that may suspend the process after an invocation, but before the Processor
exports the completed spans.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/opentelemetry/sdk/trace/multi_span_processor.rb', line 57 def force_flush(timeout: nil) start_time = Time.now results = @span_processors.map do |processor| remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time) return Export::TIMEOUT if remaining_timeout&.zero? processor.force_flush(timeout: remaining_timeout) end results.uniq.max end |
#on_finish(span) ⇒ Object
Called when a Span is ended, if the Span#recording? returns true.
This method is called synchronously on the execution thread, should not throw or block the execution thread.
42 43 44 |
# File 'lib/opentelemetry/sdk/trace/multi_span_processor.rb', line 42 def on_finish(span) @span_processors.each { |processor| processor.on_finish(span) } end |
#on_start(span, parent_context) ⇒ Object
Called when a Span is started, if the Span#recording? returns true.
This method is called synchronously on the execution thread, should not throw or block the execution thread.
31 32 33 |
# File 'lib/opentelemetry/sdk/trace/multi_span_processor.rb', line 31 def on_start(span, parent_context) @span_processors.each { |processor| processor.on_start(span, parent_context) } end |
#shutdown(timeout: nil) ⇒ Integer
Called when TracerProvider#shutdown is called.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/opentelemetry/sdk/trace/multi_span_processor.rb', line 73 def shutdown(timeout: nil) start_time = Time.now results = @span_processors.map do |processor| remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time) return Export::TIMEOUT if remaining_timeout&.zero? processor.shutdown(timeout: remaining_timeout) end results.uniq.max end |