Skip to main content
Use the spans module to search project spans and perform span-level maintenance such as deleting spans or adding notes.

Relevant Source Files

  • src/spans/getSpans.ts for the exact filter names and query behavior

Search Spans

import { getSpans } from "@arizeai/phoenix-client/spans";

const result = await getSpans({
  project: { projectName: "support-bot" },
  limit: 100,
  spanKind: ["LLM", "TOOL"],
  statusCode: "ERROR",
});

for (const span of result.spans) {
  console.log(span.name, span.context.trace_id);
}

Root Span Queries

Use parentId: null to limit results to root spans only.
const rootSpans = await getSpans({
  project: { projectName: "support-bot" },
  parentId: null,
});

Span Maintenance

import { addSpanNote, deleteSpan } from "@arizeai/phoenix-client/spans";

await addSpanNote({
  spanNote: {
    spanId: "abc123def456",
    note: "Escalated due to failed retrieval",
  },
});

await deleteSpan({
  spanIdentifier: "abc123def456",
});
deleteSpan accepts either the OpenTelemetry span_id or Phoenix’s global span ID. For span-level annotations (labels, scores, evaluations), see Span Annotations and Document Annotations.

Source Map

  • src/spans/getSpans.ts
  • src/spans/addSpanNote.ts
  • src/spans/deleteSpan.ts
  • src/spans/getSpanAnnotations.ts
  • src/types/spans.ts