Skip to main content
The traces module provides trace retrieval, project transfer, 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/transferTraces.ts for moving traces between projects
  • 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 }

Move Traces To Another Project

Use transferTraces to move one or more traces from their current project to a destination project. This operation moves rather than copies the traces: after a successful transfer, they no longer appear in the source project. All traces in one call must currently belong to the same source project. Each trace identifier can be either an OpenTelemetry trace ID or a Phoenix trace GlobalID, and the destination can be either a project name or project GlobalID.
The result contains the number of distinct traces moved and the resolved GlobalID of the destination project. Phoenix rejects an empty list, trace or project identifiers that do not resolve, and requests that combine traces from multiple source projects. transferTraces requires Phoenix server 20.4.0 or newer.

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/transferTraces.ts
  • src/traces/types.ts
  • src/types/projects.ts