Tracing stores a tree of callback runs. A top-level run becomes a trace, and child callbacks become nested runs under the sameDocumentation Index
Fetch the complete documentation index at: https://docs.m4trix.dev/llms.txt
Use this file to discover all available pages before exploring further.
traceId.
Traces and Runs
ATrace is the summary record shown in trace lists:
traceIdandrootRunIdname,status,startTime, optionalendTime, andlatencyMs- optional
projectId,metadata, token totals, and cost runCount
TraceRun is one node in the trace tree:
runId,traceId, and optionalparentRunIdtype,name,status, and timing fields- optional
inputRef,outputRef,eventsRef,tokens,error,metadata, andextra
traceId from the root run. Child runs keep their own runId and point back to their parent with parentRunId.
Run Types
Built-in run types include:agentchainllmchat_modeltoolretrieverembeddingpromptparser
runTypeOrName; otherwise they are stored as chain runs.
Payload References
Trace structure stays small. Inputs and outputs are written through the payload adapter, and runs store references to those payloads:Metadata and Project IDs
Callback metadata is copied onto trace records when values are strings, numbers, or booleans.projectId is treated specially: it becomes the trace-level projectId and is excluded from the generic metadata object.
projectId when you want viewer or API queries to filter traces by application, workflow, tenant, or experiment family.
Status and Errors
Runs start asrunning and finish as success or error. Error runs store the error message and error type:
error when any run in its tree has errored.
Flushing
Callback handlers write asynchronously.Tracer.flush() waits for pending callback work, batches pending run updates, and upserts pending trace summaries.
Call flush() when:
- a script is about to exit
- a test expects traces to be available immediately
- you are about to open the trace viewer after a short local run
Storage Adapters
TraceStore separates structure from payloads:
Trace and TraceRun records and handles list/query operations. The payload adapter stores JSON payloads and optional streams.
The package includes filesystem adapters for local development. Implement StructureStoreAdapter and PayloadStoreAdapter when you want to store traces in a database, object store, or hosted observability backend.