Principle:Wandb Weave Call Execution
| Knowledge Sources | |
|---|---|
| Domains | Observability, Distributed_Tracing |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
A trace lifecycle mechanism that creates, manages, and finalizes call records to capture the full execution context of traced operations.
Description
Call Execution is the runtime phase where traced function invocations are recorded as structured Call objects. Each Call captures the operation name, inputs, outputs, timing, exceptions, and its position in the call hierarchy (parent-child relationships via trace and parent IDs).
This principle covers the full lifecycle: creating a call when execution begins, managing a thread-local call stack for automatic parent-child linking, and finalizing the call with output data and computed summaries when execution completes.
Usage
This principle operates automatically when traced functions (decorated with @weave.op) are invoked. It can also be used explicitly via the WeaveClient API for advanced scenarios like manual call management or custom instrumentation.
Theoretical Basis
Distributed tracing systems model execution as a tree of spans (or calls):
- Call Creation: Generate a unique call ID, record start time, capture inputs, and push onto the thread-local call stack.
- Stack Management: Use the call stack to automatically determine parent-child relationships. Each new call inherits the current stack top as its parent.
- Call Finalization: Record end time, capture output or exception, compute summary statistics (token usage, status counts), and pop from the stack.
The thread-local stack ensures correct parent-child relationships even in deeply nested call chains.