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, useset_context() and clear_context():
Set context before running traced functions:
One process exports collected spans (from
@traced, start_span, or traces.generate()) through one client: the most recently created Galtea object. spans.create() and spans.create_batch() are not affected: they always use their own object’s settings. To change the API key, the API URL or the extra headers in a running process such as a notebook, create a new Galtea object. Spans then go out with the new settings, including spans not sent yet. Calling shutdown() on an older object only flushes pending spans; span export stops only when the latest object shuts down. Do not use two Galtea objects with API keys of different organizations in one process: spans of the older object’s traces are sent with the newer key, the API refuses them, and they are lost.Service Methods
Context Management
Direct API Methods
Related
Span
Understand how spans capture the internal operations of your AI agents.