Nous.Workflow.Trace (nous v0.16.3)
View SourceRecords execution traces for workflow debugging and observability.
A trace is an ordered list of node executions with timing, status, and output summaries. Traces are accumulated in-memory during execution and returned as part of the workflow state metadata.
Example
{:ok, state} = Nous.Workflow.run(graph, %{}, trace: true)
trace = state.metadata.trace
for entry <- trace.entries do
IO.puts "#{entry.node_id} (#{entry.node_type}): #{entry.status} in #{entry.duration_ms}ms"
end
Summary
Functions
Create a new empty trace.
Returns the number of nodes executed.
Record a completed node execution.
Returns the total execution time in milliseconds.
Types
@type entry() :: %{ node_id: String.t(), node_type: atom(), started_at: DateTime.t(), completed_at: DateTime.t() | nil, status: :completed | :failed | :skipped | :suspended, duration_ms: non_neg_integer(), error: term() | nil }
@type t() :: %Nous.Workflow.Trace{ entries: [entry()], run_id: String.t(), started_at: DateTime.t() }
Functions
@spec new() :: t()
Create a new empty trace.
@spec node_count(t()) :: non_neg_integer()
Returns the number of nodes executed.
@spec record( t(), String.t(), atom(), non_neg_integer(), :completed | :failed | :skipped | :suspended, term() ) :: t()
Record a completed node execution.
@spec total_duration_ms(t()) :: non_neg_integer()
Returns the total execution time in milliseconds.