Experimental
The parameters to search for spans
A paginated response containing spans and optional next cursor
// Get recent spans from a project
const result = await getSpans({
client,
project: { projectName: "my-project" },
limit: 50
});
// Get spans in a time range
const result = await getSpans({
client,
project: { projectName: "my-project" },
startTime: new Date("2024-01-01"),
endTime: new Date("2024-01-02"),
limit: 100
});
// Paginate through results
let cursor: string | undefined;
do {
const result = await getSpans({
client,
project: { projectName: "my-project" },
cursor,
limit: 100
});
// Process spans
result.spans.forEach(span => {
console.log(`Span: ${span.name}, Trace: ${span.context.trace_id}`);
});
cursor = result.nextCursor || undefined;
} while (cursor);
Get spans from a project with filtering criteria.
This method allows you to search for spans within a project using various filters such as time range and supports cursor-based pagination. The spans are returned in Phoenix's standard format with human-readable timestamps and simplified attribute structures.
this function is experimental and may change in the future