The traces module provides trace retrieval, project transfer, and trace-level annotation functions.
Relevant Source Files
src/traces/getTraces.tsfor the exact query shape and server requirementsrc/traces/addTraceAnnotation.tsfor single annotation writessrc/traces/logTraceAnnotations.tsfor batched annotation writessrc/traces/transferTraces.tsfor moving traces between projectssrc/traces/types.tsfor theTraceAnnotationtype
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#
projectstartTimeendTimesortorderlimitcursorincludeSpanssessionIdfilter— a trace DSL expression, combined with other filters using ANDerror(deprecated; usefilter)minLatencyMs(deprecated; usefilter)maxLatencyMs(deprecated; usefilter)
Notes#
getTracesrequires a Phoenix server that supports project trace listing- Use the returned
nextCursorto continue pagination - Set
includeSpanswhen you need a trace-centric fetch that also contains span details projectaccepts{ project },{ projectId }, or{ projectName }filtertakes 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, andmaxLatencyMsremain supported on Phoenix server >= 20.8.0. Replace them witherror_count > 0/error_count == 0,latency_ms >= N, andlatency_ms <= Nrespectively. 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#
| Field | Type | Required | Description |
|---|---|---|---|
traceId | string | Yes | OpenTelemetry Trace ID (hex, no 0x prefix) |
name | string | Yes | What is being measured (e.g. "groundedness"). The name "note" is reserved — use addTraceNote instead. |
annotatorKind | "HUMAN" | "LLM" | "CODE" | No | Defaults to "HUMAN" |
label | string | At least one of label/score/explanation | Categorical result (e.g. "correct") |
score | number | At least one of label/score/explanation | Numeric result (e.g. 0.95) |
explanation | string | At least one of label/score/explanation | Free-text justification |
identifier | string | No | Stable ID for idempotent upserts |
metadata | Record<string, unknown> | No | Arbitrary 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).
Source Map
src/traces/getTraces.tssrc/traces/addTraceAnnotation.tssrc/traces/logTraceAnnotations.tssrc/traces/transferTraces.tssrc/traces/types.tssrc/types/projects.ts

