The
spans client methods are generally available. The delete, list, and annotate methods are currently in BETA ā the API may change without notice, and a one-time warning is emitted on first use.Key Capabilities
- List and filter spans for a project
- Bulk upload traces from offline processing
- Update evaluations asynchronously (LLM-as-judge patterns)
- Annotate spans, traces, or sessions by ID, or attach annotations to spans in bulk
- Attach custom metadata for filtering and analysis
- Export spans for offline analysis
- Permanently delete spans by ID
List Spans
For downloading large volumes of spans, use
export_to_df instead.start_time and end_time are not provided, the last seven days are queried. start_time is inclusive and end_time is exclusive.
Filter Spans
Use thefilter parameter to narrow results by status, evaluation labels, annotation labels, or latency:
Select and Truncate Columns
Useincluded_columns or excluded_columns (full dotted column paths; mutually exclusive) to control which columns are returned for each span. Fixed span fields are always returned. Set truncate_string_length to a positive integer to shorten every string value inside each spanās attributes (at any nesting depth) to at most that many characters; truncated strings end with a single ⦠character that counts toward the limit. Span IDs, names, kinds, status, timestamps, annotations, evaluations, events, and pagination are never truncated.
Log Spans
Upload traces in bulk from offline processing or batch evaluation.Log Spans Only
Update Evaluations
Add or update evaluations for existing spans (useful for LLM-as-judge patterns).context.span_id column so each evaluation can be assigned to its span. Evaluations are sent via Flight gRPC by default; pass force_http=True to upload over HTTP, and timeout (seconds) to stop waiting for a response.
Batch Evaluation Pattern
Annotate Spans
Write human annotations to a batch of records by ID. Annotations are upserted by annotation config name for each record; submitting the same name for the same record overwrites the previous value. If any record in the batch is not found within the lookup window, the entire request is rejected with a 404 error.granularity (a RecordGranularity) selects what each record_id identifies:
granularity:
Update Annotations
Add human feedback and annotations to spans. The dataframe must contain acontext.span_id column. Annotation columns follow the pattern annotation.<name>.<suffix>, where the suffix is label, score, or text. An optional annotation.notes column can hold free-form notes.
Update Metadata
Attach or patch custom metadata on existing spans for filtering and analysis. The method uses JSON Merge Patch semantics and supports three input approaches.Method 1: Direct Field Columns
Set individual metadata fields usingattributes.metadata.<field> column names. This is the simplest approach.
Method 2: Patch Document Column
Provide a JSON patch document per span for more control. The patch is applied after any field columns. The default column name is"patch_document".
patch_document_column_name parameter:
Method 3: Combined Approach
Use both field columns and a patch document. The patch document is applied last and overrides any conflicting field column values.Type Handling
Setting a field to
None stores JSON null ā it does not remove the field. This differs from standard JSON Merge Patch behavior.Response Structure
update_metadata returns a dictionary with the following keys:
Delete Spans
Permanently delete spans by their IDs. This operation is irreversible. Only spans within the 2-year lookback window are considered; older spans are not affected. Span IDs not found within the lookback window are returned innot_deleted_span_ids. Pass start_time (inclusive) and end_time (exclusive) to scope the delete to spans starting within that window. span_ids must not be empty.
Returns a DeleteSpansResponse with:
completedāTrueif no retry is needed.deleted_span_idsā IDs confirmed deleted.not_deleted_span_idsā IDs not deleted (either not found in the lookback window, or not reached whencompletedisFalse).
completed is False, retry the original full request to complete the deletion.
Export Spans
Export spans for offline analysis, custom processing, or archival.Export to Parquet
Filter, Select, and Sample
Both export methods accept the same optional parameters:whereā SQL-like WHERE clause to filter rows (e.g."span.status_code = 'ERROR'").columnsā list of column names to include. All columns are returned when omitted.stream_chunk_sizeā chunk size for streaming large result sets.sample_rateā fraction of traces to export, in the range[1e-6, 1]. Sampling is done server-side by trace ID, so whole traces are kept together and re-runs return the same sample.Noneor1.0exports everything.
- Time-range filtering
- SQL-like row filtering, column selection, and trace sampling
- DataFrame or Parquet output
- Efficient Arrow Flight transport for large exports
- Progress bars for long-running exports