Module: Legion::LLM::Pipeline::Tracing

Defined in:
lib/legion/llm/pipeline/tracing.rb

Class Method Summary collapse

Class Method Details

.exchange_idObject



29
30
31
# File 'lib/legion/llm/pipeline/tracing.rb', line 29

def exchange_id
  "exch_#{SecureRandom.hex(12)}"
end

.init(existing: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/legion/llm/pipeline/tracing.rb', line 9

def init(existing: nil)
  if existing && existing[:trace_id]
    {
      trace_id:       existing[:trace_id],
      span_id:        SecureRandom.hex(8),
      parent_span_id: existing[:span_id],
      correlation_id: existing[:correlation_id],
      baggage:        existing[:baggage] || {}
    }
  else
    {
      trace_id:       SecureRandom.hex(16),
      span_id:        SecureRandom.hex(8),
      parent_span_id: nil,
      correlation_id: nil,
      baggage:        {}
    }
  end
end