Skip to main content

The traces module provides trace retrieval, project transfer, and trace-level annotation functions.

Retrieve Traces#

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

Supported Filters#

  • project
  • startTime
  • endTime
  • sort
  • order
  • limit
  • cursor
  • includeSpans
  • sessionId
  • filter — a trace DSL expression, combined with other filters using AND
  • error (deprecated; use filter)
  • minLatencyMs (deprecated; use filter)
  • maxLatencyMs (deprecated; use filter)

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 }
  • filter takes a trace filter expression; the language is documented on the Filter Expressions page, and its Finding field names section covers discovering valid names for your project.
  • error, minLatencyMs, and maxLatencyMs remain supported on Phoenix server >= 20.8.0. Replace them with error_count > 0 / error_count == 0, latency_ms >= N, and latency_ms <= N respectively. Latency bounds are inclusive and errors include child spans.

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#

FieldTypeRequiredDescription
traceIdstringYesOpenTelemetry Trace ID (hex, no 0x prefix)
namestringYesWhat is being measured (e.g. "groundedness"). The name "note" is reserved — use addTraceNote instead.
annotatorKind"HUMAN" | "LLM" | "CODE"NoDefaults to "HUMAN"
labelstringAt least one of label/score/explanationCategorical result (e.g. "correct")
scorenumberAt least one of label/score/explanationNumeric result (e.g. 0.95)
explanationstringAt least one of label/score/explanationFree-text justification
identifierstringNoStable ID for idempotent upserts
metadataRecord<string, unknown>NoArbitrary context

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).