Class: LlmLogs::Trace

Inherits:
ApplicationRecord show all
Defined in:
app/models/llm_logs/trace.rb

Instance Method Summary collapse

Instance Method Details

#complete!Object



13
14
15
16
17
18
19
20
21
22
# File 'app/models/llm_logs/trace.rb', line 13

def complete!
  return if status == "completed"

  rollup_stats!
  update!(
    status: "completed",
    completed_at: Time.current,
    duration_ms: (Time.current - started_at) * 1000
  )
end

#fail!Object



24
25
26
27
28
29
30
31
# File 'app/models/llm_logs/trace.rb', line 24

def fail!
  rollup_stats!
  update!(
    status: "error",
    completed_at: Time.current,
    duration_ms: (Time.current - started_at) * 1000
  )
end

#root_spansObject



33
34
35
# File 'app/models/llm_logs/trace.rb', line 33

def root_spans
  spans.where(parent_span_id: nil).order(:started_at)
end