Mastra (tracing)
Mastra (tracing)
The Mastra framework helps you build TypeScript AI agents, tools, and workflows. Respan captures Mastra agent runs, LLM generations, tool calls, and workflow spans, and can route model calls through the Respan gateway.
Set up Respan
Create an account at platform.respan.ai and grab an API key. For gateway, also add credits or a provider key.
Run npx @respan/cli setup to set up with your coding agent.
Example projects
Tracing
Gateway
Setup
Set environment variables
OPENAI_API_KEY is used by Mastra’s model provider. RESPAN_API_KEY is used to export traces to Respan.
View your trace
Open the Traces page to see workflows with agent spans, LLM generations, and tool calls.
Configuration
Attributes
In Respan()
Set tracing defaults when constructing Respan.
With propagateAttributes
Attach per-request identifiers and metadata around a Mastra run.
Examples
Tool calls
Tool executions are captured as tool spans with input, output, timing, and parent agent context.
Streaming
Streaming responses are traced as model generation spans with final content and usage metadata.