Skip to main content
The spans client’s list, delete, and annotate methods are currently in BETA. The API may change without notice, and a one-time warning is emitted on first use. All other spans methods (log, update_evaluations, update_annotations, update_metadata, export_to_df, export_to_parquet) are stable.
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 by ID or attach annotations to traces 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.

Filter Spans

Use the filter parameter to narrow results by status, evaluation labels, annotation labels, or latency:
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).

Batch Evaluation Pattern

Annotate Spans

Write human annotations to a batch of spans by ID. Annotations are upserted by annotation config name for each span; submitting the same name for the same span overwrites the previous value. Up to 1000 spans may be annotated per request. Spans are looked up within the specified 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 with a 404 error.

Update Annotations

Add human feedback and annotations to spans.

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. Returns a DeleteSpansResponse with:
  • completedTrue 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

Export capabilities:
  • Time-range filtering
  • DataFrame or Parquet output
  • Efficient Arrow Flight transport for large exports
  • Progress bars for long-running exports