Skip to main content
The spans client methods are currently in BETA. The API may change without notice. A one-time warning is emitted on first use.
Spans are the unit of work captured for an LLM application — each trace is composed of one or more hierarchical spans. The Spans subclient lets you query spans within a project (filtered by time range and an optional filter DSL), remove spans by ID, and write human annotations to a batch of spans. Project accepts a name or ID; when a name is passed, Space (name or ID) is required so the SDK can resolve the name to a unique ID.

List Spans

List returns a paginated list of spans matching the given filter. Unlike other List methods in this SDK, spans.List uses POST because the filter DSL and projection list can be too large for a query string. Both the body fields (project, time range, filter) and the query params (limit, cursor) are flattened into a single ListRequest. Signature:
Usage Example:

Delete Spans

Delete removes spans by their IDs. The response always includes Completed (whether the server fully processed the request), DeletedSpanIds (IDs confirmed deleted), and NotDeletedSpanIds (IDs not deleted — either not found within the supported lookback window, or not reached when Completed is false). When Completed is false, retry the original full request; the delete operation is idempotent, so re-submitting already-deleted IDs is safe. Signature:
Usage Example:

Annotate Spans

Annotate writes human annotations to a batch of spans. Annotations are upserted by annotation config name per span: resubmitting the same config name for the same span overwrites the previous value, so retries do not create duplicates. Up to 1000 spans may be annotated per request. Spans are looked up within the configured time window (defaulting to the last 31 days). If any span ID in the batch is not found within the window, the entire request is rejected. The write completes synchronously before the function returns (HTTP 202 Accepted); visibility in read queries may lag by a short interval. Signature:
Usage Example: