Skip to main content
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.
Log, query, and update LLM traces programmatically. Upload bulk traces or update evaluations and annotations after the fact.

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.
List spans for a project within an optional time window. Spans are returned in descending start-time order (most recent first). If 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 the filter parameter to narrow results by status, evaluation labels, annotation labels, or latency:

Select and Truncate Columns

Use included_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.
For details on pagination, field introspection, and data conversion (to dict/JSON/DataFrame), see Response Objects.

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).
The dataframe must contain a 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:
To annotate whole sessions, pass granularity:

Update Annotations

Add human feedback and annotations to spans. The dataframe must contain a context.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 using attributes.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".
Use a custom column name with the 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 in not_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 — True if 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 when completed is False).
When 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. None or 1.0 exports everything.
Export capabilities:
  • 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
Last modified on November 23, 2026