Skip to main content
The Span Service in the Galtea SDK allows you to collect, manage, and persist spans that capture the internal operations of your AI agents during inference. This Service is exposed by the galtea.spans object.
Remember that we will be using the galtea object. More information here.

Two Approaches to Span Collection

The SDK provides two ways to collect spans:

1. Automatic Collection with with generate()

When using galtea.traces.generate(), span collection is handled automatically:

2. Manual Collection with Context Management

For full control over the span lifecycle, use set_context() and clear_context(): Set context before running traced functions:
Then run your traced functions within this context set/open. Once done, clear the context to flush and detach:
Use galtea.traces.generate() for automatic span collection instead of manual collection.

Service Methods

Context Management

Direct API Methods

Span

Understand how spans capture the internal operations of your AI agents.