Skip to main content

trace_op

Function trace_op 

Source
pub fn trace_op<T>(
    f: impl FnOnce() -> VortexResult<T>,
) -> VortexResult<Traced<T>>
Expand description

Run f while capturing a trace of the optimizer and executor work it performs.

f typically invokes an operation that drives the executor or optimizer, such as ArrayOptimizer::optimize or ArrayRef::execute. While f runs, the optimizer and executor emit structured events via the trace_op! macro into a thread-local recorder. When f returns, the recorder is finalized and returned alongside the closure’s output as a Traced<T>.

The default resolution (TraceResolution::ExecutedOnly) records the rule rewrites, parent kernels, execution steps, and builder activity that actually executed. Optimizer passes that produced no change are hidden from the rendered trace. Use trace_op_with with TraceResolution::Attempts when a test needs to assert on declined rule attempts, kernels that did not match, or other fall-through detail.

§Examples

let traced = trace_op(|| filter_array.optimize())?;
assert!(traced.output.is::<Primitive>());
insta::assert_snapshot!(traced.trace.to_string(), @r"
optimize root=vortex.filter(i32, len=4) session=false
  reduce TrivialFilterRule: vortex.filter(i32, len=4) -> vortex.primitive(i32, len=4)
  done output=vortex.primitive(i32, len=4)
");

§Errors

Returns whatever error f produces. Returns an error if a recorder is already active on the current thread — nested traces are not supported.