Skip to main content
Tracing lets you build a tree of spans to visualize complex AI workflows — agents, tool calls, retrieval steps, and nested LLM generations. Traces are sent to the Know Your AI dashboard where you can inspect the full execution tree.

Concepts

Basic tracing

Span types

Generation span

Track an LLM call with model, tokens, and cost:

Agent span

Track an agent orchestration loop:

Tool span

Track a function/tool call:

Retriever span

Track a document retrieval step:

Embedding span

Track an embedding call:

Event span

Record a point-in-time event (auto-ends):

Nested spans

Spans can be nested to form a tree. Use the parent span’s helper methods:
This produces a trace tree like:

Wrapper functions

For cleaner code, use the with* wrappers. They automatically start and end spans:

Span status

Set the status of a span to indicate success or failure:

Span events

Attach events to a span for debugging:

Export / inspect

Trace transports

Configure where traces are sent:

Content deduplication

When enableDeduplication: true (default), the SDK automatically deduplicates repeated content across spans (e.g., system prompts, repeated tool outputs) to reduce payload size:

Full agentic example