Pipeline.Tracing.NestedExecution (pipeline v0.0.1)

View Source

Execution tracing and monitoring for nested pipeline execution.

Provides comprehensive tracing capabilities including span tracking, execution trees, performance metrics, and debugging information for nested pipeline workflows.

Summary

Functions

Generate an execution tree from trace spans.

Complete a span in the trace.

Create debug information for troubleshooting.

Generate performance summary from execution tree.

Generate a visual representation of the execution tree.

Types

execution_span()

@type execution_span() :: %{
  id: span_id(),
  trace_id: trace_id(),
  parent_span: span_id() | nil,
  pipeline_id: String.t(),
  step_name: String.t() | nil,
  step_type: String.t() | nil,
  depth: non_neg_integer(),
  start_time: DateTime.t(),
  end_time: DateTime.t() | nil,
  duration_ms: non_neg_integer() | nil,
  status: :running | :completed | :failed,
  error: String.t() | nil,
  metadata: map()
}

execution_tree()

@type execution_tree() :: %{
  pipeline_id: String.t(),
  spans: [execution_span()],
  children: [execution_tree()],
  total_duration_ms: non_neg_integer(),
  step_count: non_neg_integer(),
  max_depth: non_neg_integer()
}

span_id()

@type span_id() :: String.t()

trace_context()

@type trace_context() :: %{
  trace_id: trace_id(),
  current_span: span_id() | nil,
  spans: %{required(span_id()) => execution_span()},
  start_time: DateTime.t()
}

trace_id()

@type trace_id() :: String.t()

Functions

build_execution_tree(trace_context)

@spec build_execution_tree(trace_context()) :: execution_tree()

Generate an execution tree from trace spans.

Parameters

  • trace_context: Trace context containing all spans

Returns

  • Hierarchical execution tree

complete_span(trace_context, result)

@spec complete_span(trace_context(), any()) :: trace_context()

Complete a span in the trace.

Parameters

  • trace_context: Current trace context
  • result: Execution result (:ok, {:ok, value}, or {:error, reason})

Returns

  • Updated trace context

create_debug_info(trace_context, error \\ nil)

@spec create_debug_info(trace_context(), any()) :: map()

Create debug information for troubleshooting.

Parameters

  • trace_context: Current trace context
  • error: Error that occurred (optional)

Returns

  • Debug information map

generate_performance_summary(execution_tree)

@spec generate_performance_summary(execution_tree()) :: map()

Generate performance summary from execution tree.

Parameters

  • execution_tree: The execution tree to analyze

Returns

  • Performance summary with metrics by depth

start_nested_trace(pipeline_id, context, step \\ nil, parent_trace \\ nil)

@spec start_nested_trace(String.t(), map(), map() | nil, trace_context() | nil) ::
  trace_context()

Start tracing a nested pipeline execution.

Parameters

  • pipeline_id: The ID of the pipeline being executed
  • context: Current execution context
  • step: Current step configuration (optional)
  • parent_trace: Parent trace context (optional)

Returns

  • New trace context with initial span

visualize_execution_tree(execution_tree, options \\ %{})

@spec visualize_execution_tree(execution_tree(), map()) :: String.t()

Generate a visual representation of the execution tree.

Parameters

  • execution_tree: The execution tree to visualize
  • options: Visualization options (optional)

Returns

  • String representation of the execution tree