Documentation Index
Fetch the complete documentation index at: https://docs.trulayer.ai/llms.txt
Use this file to discover all available pages before exploring further.
Mastra does not have a dedicated auto-instrument yet. Until it lands, use the TruLayer TypeScript SDK’s generic
trace / span API — the pattern below covers every Mastra primitive.Install
Instrument an agent run
Wrap eachagent.generate() or agent.stream() call in a trace. If you also call the Vercel AI SDK or OpenAI SDK from within tools, stack the corresponding TruLayer instrumentations so nested spans show up in the waterfall.
Instrument a workflow step
What gets captured
- A
traceper workflow or agent run. - One
spanper workflow step or tool invocation (whatever you wrap). - Nested
llmspans automatically when the Vercel AI SDK or OpenAI SDK is also instrumented — no extra code required.
Known gotchas
- No auto-discovery yet. You must wrap each Mastra entry point explicitly. A dedicated
instrumentMastrahelper is on the roadmap. - Next.js Edge runtime is unsupported. Use
export const runtime = "nodejs"on any Route Handler that invokes instrumented code. - Streaming. When using
agent.stream(), keep the span open until the stream completes (for awaitloop inside thespan(...)callback) so token counts are recorded.