Module: Langfuse::ObservationType

Defined in:
lib/langfuse/observation_types.rb

Overview

Valid observation types for Langfuse These types provide semantic meaning to observations in traces

Constant Summary collapse

SPAN =

Core observation types (existing)

'span'
GENERATION =
'generation'
EVENT =
'event'
AGENT =

Enhanced observation types (new in 2025)

'agent'
TOOL =

Agent workflows and reasoning

'tool'
CHAIN =

Tool/function calls

'chain'
RETRIEVER =

Chain operations (e.g., retrieval chains)

'retriever'
EMBEDDING =

Data retrieval (vector stores, databases)

'embedding'
EVALUATOR =

Embedding generation

'evaluator'
GUARDRAIL =

Evaluation/scoring functions

'guardrail'
ALL =

All valid observation types

[
  SPAN,
  GENERATION,
  EVENT,
  AGENT,
  TOOL,
  CHAIN,
  RETRIEVER,
  EMBEDDING,
  EVALUATOR,
  GUARDRAIL
].freeze
SPAN_BASED =

Types that are aliases for span (use span-create/span-update events)

[
  SPAN,
  AGENT,
  TOOL,
  CHAIN,
  RETRIEVER,
  EMBEDDING,
  EVALUATOR,
  GUARDRAIL
].freeze

Class Method Summary collapse

Class Method Details

.span_based?(type) ⇒ Boolean

Check if type uses span events

Returns:



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

def self.span_based?(type)
  return true if type.nil?

  SPAN_BASED.include?(type.to_s)
end

.valid?(type) ⇒ Boolean

Validate if a type is valid

Returns:



48
49
50
51
52
# File 'lib/langfuse/observation_types.rb', line 48

def self.valid?(type)
  return true if type.nil? # nil is valid (defaults to base type)

  ALL.include?(type.to_s)
end