@@ -11,6 +11,9 @@ defmodule Pipeline.Debug.NestedExecution do
1111 alias Pipeline.Tracing.NestedExecution
1212 alias Pipeline.Error.NestedPipeline
1313
14+ # Import types from tracing module
15+ @ type trace_context :: Pipeline.Tracing.NestedExecution . trace_context ( )
16+
1417 @ type debug_session :: % {
1518 trace_context: map ( ) ,
1619 execution_tree: map ( ) ,
@@ -38,8 +41,13 @@ defmodule Pipeline.Debug.NestedExecution do
3841 ## Returns
3942 - Debug session context
4043 """
41- @ spec start_debug_session ( map ( ) , map ( ) ) :: debug_session ( )
42- def start_debug_session ( trace_context , options \\ % { } ) do
44+ @ spec start_debug_session ( trace_context ( ) ) :: debug_session ( )
45+ def start_debug_session ( trace_context ) do
46+ start_debug_session ( trace_context , % { } )
47+ end
48+
49+ @ spec start_debug_session ( trace_context ( ) , map ( ) ) :: debug_session ( )
50+ def start_debug_session ( trace_context , options ) do
4351 session_id = generate_session_id ( )
4452 execution_tree = NestedExecution . build_execution_tree ( trace_context )
4553
@@ -152,8 +160,18 @@ defmodule Pipeline.Debug.NestedExecution do
152160 ## Returns
153161 - Comprehensive debugging report
154162 """
155- @ spec generate_debug_report ( map ( ) , any ( ) , map ( ) ) :: String . t ( )
156- def generate_debug_report ( trace_context , error \\ nil , options \\ % { } ) do
163+ @ spec generate_debug_report ( trace_context ( ) ) :: String . t ( )
164+ def generate_debug_report ( trace_context ) do
165+ generate_debug_report ( trace_context , nil , % { } )
166+ end
167+
168+ @ spec generate_debug_report ( trace_context ( ) , any ( ) ) :: String . t ( )
169+ def generate_debug_report ( trace_context , error ) do
170+ generate_debug_report ( trace_context , error , % { } )
171+ end
172+
173+ @ spec generate_debug_report ( trace_context ( ) , any ( ) , map ( ) ) :: String . t ( )
174+ def generate_debug_report ( trace_context , error , options ) do
157175 execution_tree = NestedExecution . build_execution_tree ( trace_context )
158176 analysis = analyze_execution ( execution_tree , options )
159177
@@ -179,8 +197,13 @@ defmodule Pipeline.Debug.NestedExecution do
179197 ## Returns
180198 - Formatted context information
181199 """
182- @ spec inspect_context ( map ( ) , map ( ) ) :: String . t ( )
183- def inspect_context ( context , step \\ nil ) do
200+ @ spec inspect_context ( map ( ) ) :: String . t ( )
201+ def inspect_context ( context ) do
202+ inspect_context ( context , nil )
203+ end
204+
205+ @ spec inspect_context ( map ( ) , map ( ) | nil ) :: String . t ( )
206+ def inspect_context ( context , step ) do
184207 """
185208 Context Inspection:
186209 ==================
@@ -202,10 +225,20 @@ defmodule Pipeline.Debug.NestedExecution do
202225 Execution Chain:
203226 #{ format_execution_chain ( context ) }
204227
205- Memory Usage: #{ format_memory_usage ( ) }
228+ Memory Usage: #{ format_memory_usage_inline ( ) }
206229 """
207230 end
208231
232+ defp format_memory_usage_inline do
233+ try do
234+ memory_bytes = :erlang . memory ( :total )
235+ memory_mb = Float . round ( memory_bytes / 1_048_576 , 1 )
236+ "#{ memory_mb } MB"
237+ rescue
238+ _ -> "Unknown"
239+ end
240+ end
241+
209242 @ doc """
210243 Compare execution performance between different traces.
211244
@@ -851,20 +884,11 @@ defmodule Pipeline.Debug.NestedExecution do
851884 % {
852885 pipeline_id: Map . get ( context , :pipeline_id , "unknown" ) ,
853886 nesting_depth: Map . get ( context , :nesting_depth , 0 ) ,
854- parent_context: Map . get ( context , :parent_context )
887+ parent_context: Map . get ( context , :parent_context ) ,
888+ step_count: Map . get ( context , :step_count , 0 )
855889 }
856890 end
857891
858- defp format_memory_usage do
859- try do
860- memory_bytes = :erlang . memory ( :total )
861- memory_mb = Float . round ( memory_bytes / 1_048_576 , 1 )
862- "#{ memory_mb } MB"
863- rescue
864- _ -> "Unknown"
865- end
866- end
867-
868892 defp format_comparison_table ( summaries ) do
869893 header = "Execution | Duration | Success Rate | Pipelines\n "
870894 separator = "----------|----------|--------------|----------\n "
0 commit comments