Class: Langfuse::SpanProcessor Private

Inherits:
OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor
  • Object
show all
Defined in:
lib/langfuse/span_processor.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Batch span processor that owns Langfuse’s enrichment and export filtering.

Instance Method Summary collapse

Constructor Details

#initialize(config:, exporter:) ⇒ SpanProcessor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SpanProcessor.

Parameters:



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/langfuse/span_processor.rb', line 12

def initialize(config:, exporter:)
  @logger = config.logger
  @default_trace_attributes = build_default_trace_attributes(config).freeze
  @should_export_span = config.should_export_span || Langfuse.method(:default_export_span?)

  super(
    exporter,
    max_queue_size: config.batch_size * 2,
    schedule_delay: schedule_delay_for(config),
    max_export_batch_size: config.batch_size
  )
end

Instance Method Details

#on_finish(span) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Drop spans when the export filter rejects them or raises.

Parameters:

  • span (OpenTelemetry::SDK::Trace::Span)

    The span that ended



41
42
43
44
45
# File 'lib/langfuse/span_processor.rb', line 41

def on_finish(span)
  return unless should_export_span?(span)

  super
end

#on_start(span, parent_context) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Apply Langfuse trace defaults and propagated attributes before a span records work.

Parameters:

  • span (OpenTelemetry::SDK::Trace::Span)

    The span that started

  • parent_context (OpenTelemetry::Context)

    The parent context



30
31
32
33
34
35
# File 'lib/langfuse/span_processor.rb', line 30

def on_start(span, parent_context)
  return unless span.recording?

  apply_attributes(span, @default_trace_attributes)
  apply_attributes(span, propagated_attributes(parent_context))
end