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 applies default and propagated trace attributes on new spans.

On span start, this processor first applies configured trace defaults (environment/release), then overlays attributes propagated in OpenTelemetry context (user/session/metadata/tags/version). This ensures consistent trace dimensions while still honoring per-request propagation.

Instance Method Summary collapse

Constructor Details

#initialize(config: Langfuse.configuration) ⇒ 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:

  • config (Langfuse::Config, nil) (defaults to: Langfuse.configuration)

    SDK configuration used to build trace defaults



16
17
18
19
# File 'lib/langfuse/span_processor.rb', line 16

def initialize(config: Langfuse.configuration)
  @default_trace_attributes = build_default_trace_attributes(config).freeze
  super()
end

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)



56
57
58
59
60
61
# File 'lib/langfuse/span_processor.rb', line 56

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



37
38
39
# File 'lib/langfuse/span_processor.rb', line 37

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



26
27
28
29
30
31
# File 'lib/langfuse/span_processor.rb', line 26

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

  apply_attributes(span, @default_trace_attributes)
  apply_attributes(span, propagated_attributes(parent_context))
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)



45
46
47
48
49
50
# File 'lib/langfuse/span_processor.rb', line 45

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