Class: Langfuse::SpanProcessor Private

Inherits:
OpenTelemetry::SDK::Trace::SpanProcessor
  • 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.

Span processor that automatically sets propagated attributes on new spans.

This processor reads propagated attributes from OpenTelemetry context and sets them on spans when they are created. This ensures that attributes set via ‘propagate_attributes` are automatically applied to all child spans.

Instance Method Summary collapse

Instance Method Details

#force_flush(timeout: nil) ⇒ Integer

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.

Force flush (no-op for this processor)

Parameters:

  • timeout (Integer, nil) (defaults to: nil)

    Timeout in seconds (unused for this processor)

Returns:

  • (Integer)

    Always returns 0 (no timeout needed for no-op)



54
55
56
57
58
59
# File 'lib/langfuse/span_processor.rb', line 54

def force_flush(timeout: nil)
  # No-op - nothing to flush
  # Return 0 to match OpenTelemetry SDK expectation (it finds max timeout from processors)
  _ = timeout # Suppress unused argument warning
  0
end

#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.

Called when a span ends

Parameters:

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

    The span that ended



35
36
37
# File 'lib/langfuse/span_processor.rb', line 35

def on_finish(span)
  # No-op - we don't need to do anything when spans finish
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.

Called when a span starts

Parameters:

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

    The span that started

  • parent_context (OpenTelemetry::Context)

    The parent context



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/langfuse/span_processor.rb', line 19

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

  # Get propagated attributes from context
  propagated_attrs = Propagation.get_propagated_attributes_from_context(parent_context)

  # Set attributes on span
  propagated_attrs.each do |key, value|
    span.set_attribute(key, value)
  end
end

#shutdown(timeout: nil) ⇒ Integer

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.

Shutdown the processor

Parameters:

  • timeout (Integer, nil) (defaults to: nil)

    Timeout in seconds (unused for this processor)

Returns:

  • (Integer)

    Always returns 0 (no timeout needed for no-op)



43
44
45
46
47
48
# File 'lib/langfuse/span_processor.rb', line 43

def shutdown(timeout: nil)
  # No-op - nothing to clean up
  # Return 0 to match OpenTelemetry SDK expectation (it finds max timeout from processors)
  _ = timeout # Suppress unused argument warning
  0
end