Class: OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor
- Defined in:
- lib/opentelemetry/sdk/trace/export/simple_span_processor.rb
Overview
An implementation of the duck type SpanProcessor that converts the Span to ioio.opentelemetryio.opentelemetry.protoio.opentelemetry.proto.traceio.opentelemetry.proto.trace.v1io.opentelemetry.proto.trace.v1.Span and passes it to the configured exporter.
Only spans that are recorded are converted, Trace::Span#is_recording? must return true.
Instance Method Summary collapse
-
#initialize(span_exporter) ⇒ SimpleSpanProcessor
constructor
Returns a new SimpleSpanProcessor that converts spans to proto and forwards them to the given span_exporter.
-
#on_finish(span) ⇒ Object
Called when a Span is ended, if the Span#recording? returns true.
-
#on_start(span) ⇒ Object
Called when a Span is started, if the Span#recording? returns true.
-
#shutdown ⇒ Object
Called when TracerFactory#shutdown is called.
Constructor Details
#initialize(span_exporter) ⇒ SimpleSpanProcessor
Returns a new OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor that converts spans to proto and forwards them to the given span_exporter.
25 26 27 |
# File 'lib/opentelemetry/sdk/trace/export/simple_span_processor.rb', line 25 def initialize(span_exporter) @span_exporter = span_exporter end |
Instance Method Details
#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.
47 48 49 50 51 52 53 |
# File 'lib/opentelemetry/sdk/trace/export/simple_span_processor.rb', line 47 def on_finish(span) return unless span.context.trace_flags.sampled? @span_exporter&.export([span.to_span_data]) rescue => e # rubocop:disable Style/RescueStandardError OpenTelemetry.logger.error("unexpected error in span.on_finish - #{e}") end |
#on_start(span) ⇒ 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.
36 37 38 |
# File 'lib/opentelemetry/sdk/trace/export/simple_span_processor.rb', line 36 def on_start(span) # Do nothing. end |
#shutdown ⇒ Object
Called when TracerFactory#shutdown is called.
56 57 58 |
# File 'lib/opentelemetry/sdk/trace/export/simple_span_processor.rb', line 56 def shutdown @span_exporter&.shutdown end |