Skip to main content

How to Set Up Spans?

Spans help you organize and track requests across microservices within traces. A trace represents the entire journey of a request through your system, while spans are smaller units of work within that trace.
1

Initialize Spans with Trace Object

Create spans with trace object
const trace = logger.trace({id: "trace-id"});

const span = trace.span({
    id: "span-id",
    name: "customer-support--classify-question",
});
Replace ‘trace.span’ with ‘span.span’ when creating spans within an existing span
2

Alternative: Create Spans Using Logger Object

const span = logger.traceSpan("trace-id", {
    id: "span-id",
    name: "customer-support--classify-question",
});
Spans
Schedule a demo to see how Maxim AI helps teams ship reliable agents.