Skip to main content
While Polos automatically traces LLM calls, tool invocations, and workflow steps, you can add custom spans to capture additional context specific to your application.

Creating a custom span

Use ctx.step.trace() to create a custom span:
The first argument is the span name, and the second (optional) argument is a dictionary of initial attributes.

Setting attributes

You can add metadata to spans using attributes:

Adding events

Events mark specific moments within a span:

Nested spans

Spans can be nested to show hierarchical relationships:
You can also create spans within step functions:
These custom spans appear alongside automatic traces in the Polos dashboard, giving you complete visibility into your workflow execution.