Skip to main content
The traces module provides trace retrieval and trace-level annotation functions.

Relevant Source Files

  • src/traces/getTraces.ts for the exact query shape and server requirement
  • src/traces/addTraceAnnotation.ts for single annotation writes
  • src/traces/logTraceAnnotations.ts for batched annotation writes
  • src/traces/types.ts for the TraceAnnotation type

Retrieve Traces

Use getTraces when you want trace-centric pagination by project, optional inline spans, or filtering by session.

Supported Filters

  • project
  • startTime
  • endTime
  • sort
  • order
  • limit
  • cursor
  • includeSpans
  • sessionId

Notes

  • getTraces requires a Phoenix server that supports project trace listing
  • Use the returned nextCursor to continue pagination
  • Set includeSpans when you need a trace-centric fetch that also contains span details
  • project accepts { project }, { projectId }, or { projectName }

Annotate a Single Trace

Use addTraceAnnotation to attach a label, score, or explanation to one trace. If you supply an identifier, Phoenix upserts the annotation when an annotation with that identifier already exists.
Set sync: true to receive the annotation ID immediately; omit it (or pass false) for higher-throughput async writes.

TraceAnnotation Fields

Annotate Multiple Traces

Use logTraceAnnotations to batch-write annotations across many traces in a single request.
logTraceAnnotations sends all annotations in a single POST and returns an array of { id: string } objects (or an empty array when sync: false).

Source Map

  • src/traces/getTraces.ts
  • src/traces/addTraceAnnotation.ts
  • src/traces/logTraceAnnotations.ts
  • src/traces/types.ts
  • src/types/projects.ts