@mastra/mcp-docs-server 1.0.0-beta.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +3 -1
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +3 -1
- package/.docs/organized/changelogs/%40internal%2Fplayground.md +60 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +15 -15
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +3 -1
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +287 -287
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +302 -302
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +38 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +66 -66
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +522 -212
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +239 -239
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +439 -234
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +450 -211
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +202 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +448 -22
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +348 -348
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +60 -60
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +287 -287
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +106 -106
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +90 -90
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +86 -86
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +221 -221
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +70 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +403 -225
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +72 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +145 -145
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +54 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +456 -226
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +625 -229
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +71 -71
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +245 -245
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +281 -281
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +354 -156
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +545 -212
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +481 -202
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +194 -194
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +781 -235
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +198 -198
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +282 -282
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +163 -163
- package/.docs/organized/changelogs/%40mastra%2Frag.md +310 -310
- package/.docs/organized/changelogs/%40mastra%2Freact.md +328 -237
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +64 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +160 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +230 -230
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +479 -232
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +110 -110
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +15 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +98 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +93 -93
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +45 -45
- package/.docs/organized/changelogs/create-mastra.md +219 -219
- package/.docs/organized/changelogs/mastra.md +276 -276
- package/.docs/organized/code-examples/a2a.md +2 -2
- package/.docs/organized/code-examples/agent-v6.md +221 -0
- package/.docs/organized/code-examples/agui.md +4 -4
- package/.docs/organized/code-examples/ai-elements.md +3 -3
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-v5.md +3 -3
- package/.docs/organized/code-examples/assistant-ui.md +5 -5
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +3 -3
- package/.docs/organized/code-examples/client-side-tools.md +4 -4
- package/.docs/organized/code-examples/crypto-chatbot.md +5 -5
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +7 -7
- package/.docs/organized/code-examples/inngest.md +1075 -0
- package/.docs/organized/code-examples/mcp-configuration.md +1 -1
- package/.docs/organized/code-examples/mcp-server-adapters.md +2 -2
- package/.docs/organized/code-examples/memory-per-resource-example.md +3 -3
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -1
- package/.docs/organized/code-examples/memory-with-context.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
- package/.docs/organized/code-examples/quick-start.md +1 -5
- package/.docs/organized/code-examples/server-app-access.md +2 -2
- package/.docs/organized/code-examples/server-express-adapter.md +1 -1
- package/.docs/organized/code-examples/server-fastify-adapter.md +83 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +2 -2
- package/.docs/organized/code-examples/server-koa-adapter.md +94 -0
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +24 -6
- package/.docs/raw/agents/agent-approval.mdx +209 -12
- package/.docs/raw/agents/agent-memory.mdx +36 -32
- package/.docs/raw/agents/guardrails.mdx +105 -56
- package/.docs/raw/agents/network-approval.mdx +281 -0
- package/.docs/raw/agents/networks.mdx +69 -13
- package/.docs/raw/agents/overview.mdx +43 -25
- package/.docs/raw/agents/processors.mdx +234 -17
- package/.docs/raw/agents/structured-output.mdx +78 -8
- package/.docs/raw/agents/using-tools.mdx +67 -6
- package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +1 -2
- package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +1 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +1 -2
- package/.docs/raw/course/02-agent-tools-mcp/05-updating-your-agent.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/10-updating-agent-instructions-zapier.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/16-updating-agent-instructions-github.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/21-updating-agent-instructions-hackernews.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/27-updating-agent-instructions-filesystem.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +3 -3
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/07-understanding-memory-threads.md +35 -0
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +1 -1
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +4 -5
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -1
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +3 -4
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +3 -4
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +3 -4
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +3 -4
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +22 -0
- package/.docs/raw/deployment/mastra-server.mdx +140 -0
- package/.docs/raw/deployment/monorepo.mdx +106 -42
- package/.docs/raw/deployment/overview.mdx +35 -48
- package/.docs/raw/deployment/web-framework.mdx +17 -19
- package/.docs/raw/deployment/workflow-runners.mdx +16 -0
- package/.docs/raw/evals/built-in-scorers.mdx +2 -0
- package/.docs/raw/evals/custom-scorers.mdx +60 -12
- package/.docs/raw/evals/overview.mdx +6 -6
- package/.docs/raw/evals/running-in-ci.mdx +4 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +59 -2
- package/.docs/raw/getting-started/project-structure.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +17 -1
- package/.docs/raw/getting-started/studio.mdx +6 -35
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +23 -33
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1034 -80
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +32 -11
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/amazon-ec2.mdx +9 -9
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/aws-lambda.mdx +13 -16
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/azure-app-services.mdx +5 -7
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/cloudflare-deployer.mdx +8 -5
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/digital-ocean.mdx +18 -23
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/guides/deployment/inngest.mdx +673 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/netlify-deployer.mdx +7 -3
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/vercel-deployer.mdx +8 -5
- package/.docs/raw/guides/getting-started/astro.mdx +292 -451
- package/.docs/raw/guides/getting-started/express.mdx +72 -153
- package/.docs/raw/guides/getting-started/hono.mdx +227 -0
- package/.docs/raw/guides/getting-started/next-js.mdx +173 -61
- package/.docs/raw/guides/getting-started/nuxt.mdx +505 -0
- package/.docs/raw/guides/getting-started/quickstart.mdx +5 -5
- package/.docs/raw/guides/getting-started/sveltekit.mdx +238 -409
- package/.docs/raw/guides/getting-started/vite-react.mdx +317 -147
- package/.docs/raw/guides/guide/ai-recruiter.mdx +10 -10
- package/.docs/raw/guides/guide/chef-michel.mdx +9 -11
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +15 -15
- package/.docs/raw/guides/guide/research-assistant.mdx +20 -20
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +38 -38
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/index.mdx +0 -1
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +105 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +15 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +170 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/deployment.mdx +42 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +0 -35
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +40 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +17 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/rag.mdx +47 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +271 -25
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +72 -17
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +46 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +50 -7
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mastra-cloud/deployment.mdx +86 -0
- package/.docs/raw/mastra-cloud/observability.mdx +43 -0
- package/.docs/raw/mastra-cloud/overview.mdx +31 -0
- package/.docs/raw/mastra-cloud/setup.mdx +64 -0
- package/.docs/raw/mastra-cloud/studio.mdx +35 -0
- package/.docs/raw/mcp/overview.mdx +60 -25
- package/.docs/raw/mcp/publishing-mcp-server.mdx +7 -4
- package/.docs/raw/memory/memory-processors.mdx +17 -12
- package/.docs/raw/memory/message-history.mdx +72 -0
- package/.docs/raw/memory/overview.mdx +38 -76
- package/.docs/raw/memory/semantic-recall.mdx +65 -52
- package/.docs/raw/memory/storage.mdx +248 -0
- package/.docs/raw/memory/working-memory.mdx +24 -13
- package/.docs/raw/observability/logging.mdx +16 -15
- package/.docs/raw/observability/overview.mdx +27 -7
- package/.docs/raw/observability/tracing/bridges/otel.mdx +7 -4
- package/.docs/raw/observability/tracing/exporters/arize.mdx +61 -24
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +24 -5
- package/.docs/raw/observability/tracing/exporters/datadog.mdx +175 -0
- package/.docs/raw/observability/tracing/exporters/default.mdx +28 -7
- package/.docs/raw/observability/tracing/exporters/laminar.mdx +89 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +31 -22
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +33 -3
- package/.docs/raw/observability/tracing/exporters/otel.mdx +194 -22
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/sentry.mdx +198 -0
- package/.docs/raw/observability/tracing/overview.mdx +388 -108
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +27 -7
- package/.docs/raw/rag/chunking-and-embedding.mdx +22 -33
- package/.docs/raw/rag/graph-rag.mdx +223 -0
- package/.docs/raw/rag/overview.mdx +6 -3
- package/.docs/raw/rag/retrieval.mdx +53 -57
- package/.docs/raw/rag/vector-databases.mdx +55 -31
- package/.docs/raw/reference/agents/agent.mdx +17 -14
- package/.docs/raw/reference/agents/generate.mdx +172 -44
- package/.docs/raw/reference/agents/generateLegacy.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDescription.mdx +3 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +5 -3
- package/.docs/raw/reference/agents/getLLM.mdx +5 -3
- package/.docs/raw/reference/agents/getMemory.mdx +5 -3
- package/.docs/raw/reference/agents/getModel.mdx +5 -3
- package/.docs/raw/reference/agents/getTools.mdx +4 -2
- package/.docs/raw/reference/agents/getVoice.mdx +4 -2
- package/.docs/raw/reference/agents/listAgents.mdx +4 -2
- package/.docs/raw/reference/agents/listScorers.mdx +5 -3
- package/.docs/raw/reference/agents/listTools.mdx +4 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +4 -2
- package/.docs/raw/reference/agents/network.mdx +113 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +5 -3
- package/.docs/raw/reference/ai-sdk/network-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +10 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +130 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +110 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +122 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +7 -4
- package/.docs/raw/reference/auth/auth0.mdx +5 -3
- package/.docs/raw/reference/auth/clerk.mdx +5 -3
- package/.docs/raw/reference/auth/firebase.mdx +6 -5
- package/.docs/raw/reference/auth/jwt.mdx +5 -3
- package/.docs/raw/reference/auth/supabase.mdx +5 -3
- package/.docs/raw/reference/auth/workos.mdx +5 -3
- package/.docs/raw/reference/cli/create-mastra.mdx +12 -10
- package/.docs/raw/reference/cli/mastra.mdx +63 -15
- package/.docs/raw/reference/client-js/agents.mdx +77 -35
- package/.docs/raw/reference/client-js/error-handling.mdx +3 -3
- package/.docs/raw/reference/client-js/logs.mdx +2 -0
- package/.docs/raw/reference/client-js/mastra-client.mdx +4 -2
- package/.docs/raw/reference/client-js/memory.mdx +43 -1
- package/.docs/raw/reference/client-js/observability.mdx +2 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +2 -0
- package/.docs/raw/reference/client-js/tools.mdx +2 -0
- package/.docs/raw/reference/client-js/vectors.mdx +2 -0
- package/.docs/raw/reference/client-js/workflows.mdx +47 -3
- package/.docs/raw/reference/configuration.mdx +761 -0
- package/.docs/raw/reference/core/addGateway.mdx +2 -0
- package/.docs/raw/reference/core/getAgent.mdx +3 -1
- package/.docs/raw/reference/core/getAgentById.mdx +3 -1
- package/.docs/raw/reference/core/getDeployer.mdx +3 -1
- package/.docs/raw/reference/core/getGateway.mdx +2 -0
- package/.docs/raw/reference/core/getGatewayById.mdx +2 -0
- package/.docs/raw/reference/core/getLogger.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +3 -1
- package/.docs/raw/reference/core/getMemory.mdx +7 -3
- package/.docs/raw/reference/core/getScorer.mdx +2 -0
- package/.docs/raw/reference/core/getScorerById.mdx +2 -0
- package/.docs/raw/reference/core/getServer.mdx +6 -4
- package/.docs/raw/reference/core/getStorage.mdx +5 -3
- package/.docs/raw/reference/core/getStoredAgentById.mdx +6 -4
- package/.docs/raw/reference/core/getTelemetry.mdx +3 -1
- package/.docs/raw/reference/core/getVector.mdx +3 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +3 -1
- package/.docs/raw/reference/core/listAgents.mdx +3 -1
- package/.docs/raw/reference/core/listGateways.mdx +2 -0
- package/.docs/raw/reference/core/listLogs.mdx +3 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +3 -1
- package/.docs/raw/reference/core/listMCPServers.mdx +3 -1
- package/.docs/raw/reference/core/listMemory.mdx +8 -4
- package/.docs/raw/reference/core/listScorers.mdx +2 -0
- package/.docs/raw/reference/core/listStoredAgents.mdx +7 -5
- package/.docs/raw/reference/core/listVectors.mdx +3 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +3 -1
- package/.docs/raw/reference/core/mastra-class.mdx +27 -20
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +2 -0
- package/.docs/raw/reference/core/setLogger.mdx +3 -1
- package/.docs/raw/reference/core/setStorage.mdx +6 -4
- package/.docs/raw/reference/deployer/cloudflare.mdx +22 -53
- package/.docs/raw/reference/deployer/deployer.mdx +2 -1
- package/.docs/raw/reference/deployer/netlify.mdx +4 -1
- package/.docs/raw/reference/deployer/vercel.mdx +5 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +4 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/bias.mdx +4 -1
- package/.docs/raw/reference/evals/completeness.mdx +4 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/context-precision.mdx +4 -1
- package/.docs/raw/reference/evals/context-relevance.mdx +2 -0
- package/.docs/raw/reference/evals/create-scorer.mdx +11 -3
- package/.docs/raw/reference/evals/faithfulness.mdx +4 -1
- package/.docs/raw/reference/evals/hallucination.mdx +4 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +4 -1
- package/.docs/raw/reference/evals/mastra-scorer.mdx +2 -0
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +2 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +9 -7
- package/.docs/raw/reference/evals/run-evals.mdx +3 -1
- package/.docs/raw/reference/evals/scorer-utils.mdx +3 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +4 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +4 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +25 -23
- package/.docs/raw/reference/evals/toxicity.mdx +4 -1
- package/.docs/raw/reference/index.mdx +2 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +10 -8
- package/.docs/raw/reference/memory/clone-utilities.mdx +345 -0
- package/.docs/raw/reference/memory/cloneThread.mdx +237 -0
- package/.docs/raw/reference/memory/createThread.mdx +6 -4
- package/.docs/raw/reference/memory/deleteMessages.mdx +4 -2
- package/.docs/raw/reference/memory/getThreadById.mdx +3 -1
- package/.docs/raw/reference/memory/listThreads.mdx +187 -0
- package/.docs/raw/reference/memory/memory-class.mdx +27 -20
- package/.docs/raw/reference/memory/recall.mdx +6 -4
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +6 -2
- package/.docs/raw/reference/observability/tracing/configuration.mdx +51 -0
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +25 -6
- package/.docs/raw/reference/observability/tracing/exporters/braintrust.mdx +23 -2
- package/.docs/raw/reference/observability/tracing/exporters/cloud-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/console-exporter.mdx +3 -0
- package/.docs/raw/reference/observability/tracing/exporters/datadog.mdx +172 -0
- package/.docs/raw/reference/observability/tracing/exporters/default-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/laminar.mdx +139 -0
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +26 -4
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +51 -34
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +25 -4
- package/.docs/raw/reference/observability/tracing/exporters/sentry.mdx +224 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +20 -0
- package/.docs/raw/reference/observability/tracing/processors/sensitive-data-filter.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/spans.mdx +2 -0
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +4 -2
- package/.docs/raw/reference/processors/language-detector.mdx +6 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +5 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +6 -4
- package/.docs/raw/reference/processors/pii-detector.mdx +6 -4
- package/.docs/raw/reference/processors/processor-interface.mdx +326 -23
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +5 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +7 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +5 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +62 -19
- package/.docs/raw/reference/processors/tool-call-filter.mdx +5 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +6 -3
- package/.docs/raw/reference/processors/working-memory-processor.mdx +6 -3
- package/.docs/raw/reference/rag/chunk.mdx +7 -6
- package/.docs/raw/reference/rag/database-config.mdx +8 -6
- package/.docs/raw/reference/rag/document.mdx +2 -0
- package/.docs/raw/reference/rag/embeddings.mdx +2 -0
- package/.docs/raw/reference/rag/extract-params.mdx +57 -3
- package/.docs/raw/reference/rag/graph-rag.mdx +2 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +27 -7
- package/.docs/raw/reference/rag/rerank.mdx +2 -0
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +2 -0
- package/.docs/raw/reference/server/create-route.mdx +34 -18
- package/.docs/raw/reference/server/express-adapter.mdx +27 -51
- package/.docs/raw/reference/server/fastify-adapter.mdx +130 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +27 -51
- package/.docs/raw/reference/server/koa-adapter.mdx +129 -0
- package/.docs/raw/reference/server/mastra-server.mdx +52 -34
- package/.docs/raw/reference/server/routes.mdx +73 -10
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +10 -5
- package/.docs/raw/reference/storage/cloudflare.mdx +12 -2
- package/.docs/raw/reference/storage/composite.mdx +245 -0
- package/.docs/raw/reference/storage/convex.mdx +8 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +134 -8
- package/.docs/raw/reference/storage/lance.mdx +9 -5
- package/.docs/raw/reference/storage/libsql.mdx +76 -54
- package/.docs/raw/reference/storage/mongodb.mdx +115 -16
- package/.docs/raw/reference/storage/mssql.mdx +11 -6
- package/.docs/raw/{server-db/storage.mdx → reference/storage/overview.mdx} +15 -111
- package/.docs/raw/reference/storage/postgresql.mdx +228 -83
- package/.docs/raw/reference/storage/upstash.mdx +78 -2
- package/.docs/raw/reference/streaming/ChunkType.mdx +31 -3
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +67 -6
- package/.docs/raw/reference/streaming/agents/stream.mdx +48 -51
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +5 -3
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +37 -22
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +6 -4
- package/.docs/raw/reference/templates/overview.mdx +3 -2
- package/.docs/raw/reference/tools/client.mdx +3 -0
- package/.docs/raw/reference/tools/create-tool.mdx +127 -5
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +2 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +40 -3
- package/.docs/raw/reference/tools/mcp-client.mdx +110 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +278 -24
- package/.docs/raw/reference/tools/vector-query-tool.mdx +68 -4
- package/.docs/raw/reference/vectors/astra.mdx +5 -3
- package/.docs/raw/reference/vectors/chroma.mdx +5 -3
- package/.docs/raw/reference/vectors/convex.mdx +14 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +7 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +12 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +12 -4
- package/.docs/raw/reference/vectors/lance.mdx +6 -4
- package/.docs/raw/reference/vectors/libsql.mdx +66 -13
- package/.docs/raw/reference/vectors/mongodb.mdx +90 -10
- package/.docs/raw/reference/vectors/opensearch.mdx +30 -3
- package/.docs/raw/reference/vectors/pg.mdx +58 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +23 -8
- package/.docs/raw/reference/vectors/qdrant.mdx +148 -4
- package/.docs/raw/reference/vectors/s3vectors.mdx +8 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +6 -4
- package/.docs/raw/reference/vectors/upstash.mdx +60 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +5 -3
- package/.docs/raw/reference/voice/azure.mdx +2 -0
- package/.docs/raw/reference/voice/cloudflare.mdx +2 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +4 -0
- package/.docs/raw/reference/voice/deepgram.mdx +2 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +2 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +3 -0
- package/.docs/raw/reference/voice/google.mdx +2 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +2 -0
- package/.docs/raw/reference/voice/murf.mdx +2 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +3 -0
- package/.docs/raw/reference/voice/openai.mdx +2 -0
- package/.docs/raw/reference/voice/playai.mdx +2 -0
- package/.docs/raw/reference/voice/sarvam.mdx +2 -0
- package/.docs/raw/reference/voice/speechify.mdx +2 -0
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +3 -0
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +4 -0
- package/.docs/raw/reference/voice/voice.close.mdx +3 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +5 -1
- package/.docs/raw/reference/voice/voice.events.mdx +2 -0
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +3 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +6 -0
- package/.docs/raw/reference/voice/voice.off.mdx +2 -0
- package/.docs/raw/reference/voice/voice.on.mdx +5 -1
- package/.docs/raw/reference/voice/voice.send.mdx +4 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +6 -0
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +2 -0
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +55 -5
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +6 -4
- package/.docs/raw/reference/workflows/run-methods/start.mdx +7 -5
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +145 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +10 -8
- package/.docs/raw/reference/workflows/run.mdx +11 -3
- package/.docs/raw/reference/workflows/step.mdx +56 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +39 -2
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +71 -4
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +9 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow.mdx +193 -2
- package/.docs/raw/{auth → server/auth}/auth0.mdx +40 -21
- package/.docs/raw/{auth → server/auth}/clerk.mdx +37 -16
- package/.docs/raw/{auth → server/auth}/firebase.mdx +47 -25
- package/.docs/raw/{auth → server/auth}/index.mdx +8 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +22 -10
- package/.docs/raw/{auth → server/auth}/supabase.mdx +45 -25
- package/.docs/raw/{auth → server/auth}/workos.mdx +39 -20
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +40 -24
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +6 -6
- package/.docs/raw/{server-db → server}/mastra-client.mdx +35 -38
- package/.docs/raw/server/mastra-server.mdx +86 -0
- package/.docs/raw/{server-db → server}/middleware.mdx +11 -9
- package/.docs/raw/{server-db → server}/request-context.mdx +85 -43
- package/.docs/raw/{server-db → server}/server-adapters.mdx +154 -33
- package/.docs/raw/streaming/events.mdx +16 -7
- package/.docs/raw/streaming/overview.mdx +30 -17
- package/.docs/raw/streaming/tool-streaming.mdx +8 -6
- package/.docs/raw/streaming/workflow-streaming.mdx +8 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +4 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +46 -12
- package/.docs/raw/tools-mcp/overview.mdx +14 -13
- package/.docs/raw/voice/overview.mdx +17 -2
- package/.docs/raw/voice/speech-to-speech.mdx +5 -0
- package/.docs/raw/voice/speech-to-text.mdx +4 -0
- package/.docs/raw/voice/text-to-speech.mdx +3 -0
- package/.docs/raw/workflows/agents-and-tools.mdx +70 -21
- package/.docs/raw/workflows/control-flow.mdx +369 -34
- package/.docs/raw/workflows/error-handling.mdx +192 -18
- package/.docs/raw/workflows/human-in-the-loop.mdx +8 -7
- package/.docs/raw/workflows/input-data-mapping.mdx +9 -7
- package/.docs/raw/workflows/overview.mdx +80 -34
- package/.docs/raw/workflows/snapshots.mdx +19 -45
- package/.docs/raw/workflows/suspend-and-resume.mdx +14 -14
- package/.docs/raw/workflows/time-travel.mdx +25 -21
- package/.docs/raw/workflows/workflow-state.mdx +7 -8
- package/CHANGELOG.md +260 -0
- package/README.md +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +746 -49
- package/dist/tools/course.d.ts.map +1 -1
- package/dist/tools/embedded-docs.d.ts +276 -0
- package/dist/tools/embedded-docs.d.ts.map +1 -0
- package/package.json +9 -8
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/building-mastra.mdx +0 -73
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- package/.docs/raw/deployment/mastra-cloud/dashboard.mdx +0 -100
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +0 -53
- package/.docs/raw/deployment/mastra-cloud/overview.mdx +0 -65
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +0 -105
- package/.docs/raw/memory/conversation-history.mdx +0 -24
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +0 -140
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -150
- package/.docs/raw/memory/storage/memory-with-pg.mdx +0 -138
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +0 -146
- package/.docs/raw/memory/threads-and-resources.mdx +0 -95
- package/.docs/raw/reference/core/setTelemetry.mdx +0 -36
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +0 -110
- package/.docs/raw/reference/memory/query.mdx +0 -189
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +0 -70
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +0 -66
- package/.docs/raw/server-db/mastra-server.mdx +0 -97
- package/.docs/raw/workflows/inngest-workflow.mdx +0 -363
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Tracing | Observability"
|
|
3
3
|
description: "Set up Tracing for Mastra applications"
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/arize"
|
|
6
|
+
- "@mastra/core"
|
|
7
|
+
- "@mastra/observability"
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# Tracing
|
|
@@ -21,52 +25,27 @@ Traces are created by:
|
|
|
21
25
|
|
|
22
26
|
### Basic Config
|
|
23
27
|
|
|
24
|
-
```ts title="src/mastra/index.ts"
|
|
28
|
+
```ts title="src/mastra/index.ts"
|
|
25
29
|
import { Mastra } from "@mastra/core";
|
|
26
|
-
import { Observability } from "@mastra/observability";
|
|
27
|
-
|
|
28
|
-
export const mastra = new Mastra({
|
|
29
|
-
// ... other config
|
|
30
|
-
observability: new Observability({
|
|
31
|
-
default: { enabled: true }, // Enables DefaultExporter and CloudExporter
|
|
32
|
-
}),
|
|
33
|
-
storage: new LibSQLStore({
|
|
34
|
-
id: 'mastra-storage',
|
|
35
|
-
url: "file:./mastra.db", // Storage is required for tracing
|
|
36
|
-
}),
|
|
37
|
-
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
When enabled, the default configuration automatically includes:
|
|
41
|
-
|
|
42
|
-
- **Service Name**: `"mastra"`
|
|
43
|
-
- **Sampling**: `"always"`- Sample (100% of traces)
|
|
44
|
-
- **Exporters**:
|
|
45
|
-
- `DefaultExporter` - Persists traces to your configured storage
|
|
46
|
-
- `CloudExporter` - Sends traces to Mastra Cloud (requires `MASTRA_CLOUD_ACCESS_TOKEN`)
|
|
47
|
-
- **Span Output Processors**: `SensitiveDataFilter` - Automatically redacts sensitive fields
|
|
48
|
-
|
|
49
|
-
### Expanded Basic Config
|
|
50
|
-
|
|
51
|
-
This default configuration is a minimal helper that equates to this more verbose configuration:
|
|
52
|
-
|
|
53
|
-
```ts title="src/mastra/index.ts" showLineNumbers copy
|
|
54
30
|
import {
|
|
55
31
|
Observability,
|
|
56
|
-
CloudExporter,
|
|
57
32
|
DefaultExporter,
|
|
33
|
+
CloudExporter,
|
|
58
34
|
SensitiveDataFilter,
|
|
59
35
|
} from "@mastra/observability";
|
|
60
36
|
|
|
61
37
|
export const mastra = new Mastra({
|
|
62
|
-
// ... other config
|
|
63
38
|
observability: new Observability({
|
|
64
39
|
configs: {
|
|
65
40
|
default: {
|
|
66
41
|
serviceName: "mastra",
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
42
|
+
exporters: [
|
|
43
|
+
new DefaultExporter(), // Persists traces to storage for Mastra Studio
|
|
44
|
+
new CloudExporter(), // Sends traces to Mastra Cloud (if MASTRA_CLOUD_ACCESS_TOKEN is set)
|
|
45
|
+
],
|
|
46
|
+
spanOutputProcessors: [
|
|
47
|
+
new SensitiveDataFilter(), // Redacts sensitive data like passwords, tokens, keys
|
|
48
|
+
],
|
|
70
49
|
},
|
|
71
50
|
},
|
|
72
51
|
}),
|
|
@@ -77,13 +56,22 @@ export const mastra = new Mastra({
|
|
|
77
56
|
});
|
|
78
57
|
```
|
|
79
58
|
|
|
59
|
+
This configuration includes:
|
|
60
|
+
|
|
61
|
+
- **Service Name**: `"mastra"` - identifies your service in traces
|
|
62
|
+
- **Sampling**: `"always"` by default (100% of traces)
|
|
63
|
+
- **Exporters**:
|
|
64
|
+
- `DefaultExporter` - Persists traces to your configured storage for Mastra Studio
|
|
65
|
+
- `CloudExporter` - Sends traces to Mastra Cloud (requires `MASTRA_CLOUD_ACCESS_TOKEN`)
|
|
66
|
+
- **Span Output Processors**: `SensitiveDataFilter` - Redacts sensitive fields
|
|
67
|
+
|
|
80
68
|
## Exporters
|
|
81
69
|
|
|
82
|
-
Exporters determine where your trace data is sent and how it's stored.
|
|
70
|
+
Exporters determine where your trace data is sent and how it's stored. They integrate with your existing observability stack, support data residency requirements, and can be optimized for cost and performance. You can use multiple exporters simultaneously to send the same trace data to different destinations — for example, storing detailed traces locally for debugging while sending sampled data to a cloud provider for production monitoring.
|
|
83
71
|
|
|
84
72
|
### Internal Exporters
|
|
85
73
|
|
|
86
|
-
Mastra provides two built-in exporters
|
|
74
|
+
Mastra provides two built-in exporters:
|
|
87
75
|
|
|
88
76
|
- **[Default](/docs/v1/observability/tracing/exporters/default)** - Persists traces to local storage for viewing in Studio
|
|
89
77
|
- **[Cloud](/docs/v1/observability/tracing/exporters/cloud)** - Sends traces to Mastra Cloud for production monitoring and collaboration
|
|
@@ -94,10 +82,14 @@ In addition to the internal exporters, Mastra supports integration with popular
|
|
|
94
82
|
|
|
95
83
|
- **[Arize](/docs/v1/observability/tracing/exporters/arize)** - Exports traces to Arize Phoenix or Arize AX using OpenInference semantic conventions
|
|
96
84
|
- **[Braintrust](/docs/v1/observability/tracing/exporters/braintrust)** - Exports traces to Braintrust's eval and observability platform
|
|
85
|
+
- **[Datadog](/docs/v1/observability/tracing/exporters/datadog)** - Sends traces to Datadog APM via OTLP for full-stack observability with AI tracing
|
|
86
|
+
- **[Laminar](/docs/v1/observability/tracing/exporters/laminar)** - Sends traces to Laminar via OTLP/HTTP (protobuf) with Laminar-native span attributes + scorer support
|
|
97
87
|
- **[Langfuse](/docs/v1/observability/tracing/exporters/langfuse)** - Sends traces to the Langfuse open-source LLM engineering platform
|
|
98
88
|
- **[LangSmith](/docs/v1/observability/tracing/exporters/langsmith)** - Pushes traces into LangSmith's observability and evaluation toolkit
|
|
89
|
+
- **[PostHog](/docs/v1/observability/tracing/exporters/posthog)** - Sends traces to PostHog for AI analytics and product insights
|
|
90
|
+
- **[Sentry](/docs/v1/observability/tracing/exporters/sentry)** - Sends traces to Sentry for AI tracing and monitoring using OpenTelemetry semantic conventions
|
|
99
91
|
- **[OpenTelemetry](/docs/v1/observability/tracing/exporters/otel)** - Deliver traces to any OpenTelemetry-compatible observability system
|
|
100
|
-
- Supports: Dash0, MLflow,
|
|
92
|
+
- Supports: Dash0, MLflow, New Relic, SigNoz, Traceloop, Zipkin, and others!
|
|
101
93
|
|
|
102
94
|
## Bridges
|
|
103
95
|
|
|
@@ -174,7 +166,7 @@ sampling: {
|
|
|
174
166
|
|
|
175
167
|
### Complete Example
|
|
176
168
|
|
|
177
|
-
```ts title="src/mastra/index.ts"
|
|
169
|
+
```ts title="src/mastra/index.ts"
|
|
178
170
|
export const mastra = new Mastra({
|
|
179
171
|
observability: new Observability({
|
|
180
172
|
configs: {
|
|
@@ -214,7 +206,7 @@ Note that only a single config can be used for a specific execution. But a singl
|
|
|
214
206
|
|
|
215
207
|
Use `configSelector` to choose the appropriate tracing configuration based on request context:
|
|
216
208
|
|
|
217
|
-
```ts title="src/mastra/index.ts"
|
|
209
|
+
```ts title="src/mastra/index.ts"
|
|
218
210
|
export const mastra = new Mastra({
|
|
219
211
|
observability: new Observability({
|
|
220
212
|
configs: {
|
|
@@ -259,7 +251,7 @@ export const mastra = new Mastra({
|
|
|
259
251
|
|
|
260
252
|
A common pattern is to select configurations based on deployment environment:
|
|
261
253
|
|
|
262
|
-
```ts title="src/mastra/index.ts"
|
|
254
|
+
```ts title="src/mastra/index.ts"
|
|
263
255
|
export const mastra = new Mastra({
|
|
264
256
|
observability: new Observability({
|
|
265
257
|
configs: {
|
|
@@ -289,47 +281,35 @@ export const mastra = new Mastra({
|
|
|
289
281
|
|
|
290
282
|
### Common Configuration Patterns & Troubleshooting
|
|
291
283
|
|
|
292
|
-
#### Default & Custom Configs
|
|
293
|
-
|
|
294
|
-
Having both the default config enabled and adding custom configs is an invalid configuration of Observability. Use either the default or custom config, but not both.
|
|
295
|
-
|
|
296
|
-
```ts title="src/mastra/index.ts" showLineNumbers copy
|
|
297
|
-
export const mastra = new Mastra({
|
|
298
|
-
observability: new Observability({
|
|
299
|
-
default: { enabled: true }, // This will always be used!
|
|
300
|
-
configs: {
|
|
301
|
-
langfuse: {
|
|
302
|
-
serviceName: "my-service",
|
|
303
|
-
exporters: [langfuseExporter], // This won't be reached
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
}),
|
|
307
|
-
});
|
|
308
|
-
```
|
|
309
|
-
|
|
310
284
|
#### Maintaining Studio and Cloud Access
|
|
311
285
|
|
|
312
|
-
When
|
|
286
|
+
When adding external exporters, include `DefaultExporter` and `CloudExporter` to maintain access to Studio and Mastra Cloud:
|
|
313
287
|
|
|
314
|
-
```ts title="src/mastra/index.ts"
|
|
315
|
-
import {
|
|
288
|
+
```ts title="src/mastra/index.ts"
|
|
289
|
+
import {
|
|
290
|
+
Observability,
|
|
291
|
+
DefaultExporter,
|
|
292
|
+
CloudExporter,
|
|
293
|
+
SensitiveDataFilter,
|
|
294
|
+
} from "@mastra/observability";
|
|
316
295
|
import { ArizeExporter } from "@mastra/arize";
|
|
317
296
|
|
|
318
297
|
export const mastra = new Mastra({
|
|
319
298
|
observability: new Observability({
|
|
320
|
-
default: { enabled: false }, // Disable default to use custom
|
|
321
299
|
configs: {
|
|
322
300
|
production: {
|
|
323
301
|
serviceName: "my-service",
|
|
324
302
|
exporters: [
|
|
325
303
|
new ArizeExporter({
|
|
326
|
-
// External exporter
|
|
327
304
|
endpoint: process.env.PHOENIX_ENDPOINT,
|
|
328
305
|
apiKey: process.env.PHOENIX_API_KEY,
|
|
329
306
|
}),
|
|
330
307
|
new DefaultExporter(), // Keep Studio access
|
|
331
308
|
new CloudExporter(), // Keep Cloud access
|
|
332
309
|
],
|
|
310
|
+
spanOutputProcessors: [
|
|
311
|
+
new SensitiveDataFilter(),
|
|
312
|
+
],
|
|
333
313
|
},
|
|
334
314
|
},
|
|
335
315
|
}),
|
|
@@ -354,13 +334,13 @@ Custom metadata allows you to attach additional context to your traces, making i
|
|
|
354
334
|
|
|
355
335
|
You can add metadata to any span using the tracing context:
|
|
356
336
|
|
|
357
|
-
```ts
|
|
358
|
-
execute: async (
|
|
337
|
+
```ts
|
|
338
|
+
execute: async (inputData, context) => {
|
|
359
339
|
const startTime = Date.now();
|
|
360
340
|
const response = await fetch(inputData.endpoint);
|
|
361
341
|
|
|
362
342
|
// Add custom metadata to the current span
|
|
363
|
-
tracingContext.currentSpan?.update({
|
|
343
|
+
context?.tracingContext.currentSpan?.update({
|
|
364
344
|
metadata: {
|
|
365
345
|
apiStatusCode: response.status,
|
|
366
346
|
endpoint: inputData.endpoint,
|
|
@@ -384,7 +364,7 @@ Instead of manually adding metadata to each span, you can configure Mastra to au
|
|
|
384
364
|
|
|
385
365
|
Define which RequestContext keys to extract in your tracing configuration. These keys will be automatically included as metadata for all spans created with this configuration:
|
|
386
366
|
|
|
387
|
-
```ts title="src/mastra/index.ts"
|
|
367
|
+
```ts title="src/mastra/index.ts"
|
|
388
368
|
export const mastra = new Mastra({
|
|
389
369
|
observability: new Observability({
|
|
390
370
|
configs: {
|
|
@@ -400,15 +380,14 @@ export const mastra = new Mastra({
|
|
|
400
380
|
|
|
401
381
|
Now when you execute agents or workflows with a RequestContext, these values are automatically extracted:
|
|
402
382
|
|
|
403
|
-
```ts
|
|
383
|
+
```ts
|
|
404
384
|
const requestContext = new RequestContext();
|
|
405
385
|
requestContext.set("userId", "user-123");
|
|
406
386
|
requestContext.set("environment", "production");
|
|
407
387
|
requestContext.set("tenantId", "tenant-456");
|
|
408
388
|
|
|
409
389
|
// All spans in this trace automatically get userId, environment, and tenantId metadata
|
|
410
|
-
const result = await agent.generate({
|
|
411
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
390
|
+
const result = await agent.generate("Hello", {
|
|
412
391
|
requestContext,
|
|
413
392
|
});
|
|
414
393
|
```
|
|
@@ -417,14 +396,13 @@ const result = await agent.generate({
|
|
|
417
396
|
|
|
418
397
|
You can add trace-specific keys using `tracingOptions.requestContextKeys`. These are merged with the configuration-level keys:
|
|
419
398
|
|
|
420
|
-
```ts
|
|
399
|
+
```ts
|
|
421
400
|
const requestContext = new RequestContext();
|
|
422
401
|
requestContext.set("userId", "user-123");
|
|
423
402
|
requestContext.set("environment", "production");
|
|
424
403
|
requestContext.set("experimentId", "exp-789");
|
|
425
404
|
|
|
426
|
-
const result = await agent.generate({
|
|
427
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
405
|
+
const result = await agent.generate("Hello", {
|
|
428
406
|
requestContext,
|
|
429
407
|
tracingOptions: {
|
|
430
408
|
requestContextKeys: ["experimentId"], // Adds to configured keys
|
|
@@ -438,7 +416,7 @@ const result = await agent.generate({
|
|
|
438
416
|
|
|
439
417
|
Use dot notation to extract nested values from RequestContext:
|
|
440
418
|
|
|
441
|
-
```ts
|
|
419
|
+
```ts
|
|
442
420
|
export const mastra = new Mastra({
|
|
443
421
|
observability: new Observability({
|
|
444
422
|
configs: {
|
|
@@ -470,10 +448,9 @@ Tags are string labels that help you categorize and filter traces. Unlike metada
|
|
|
470
448
|
|
|
471
449
|
Use `tracingOptions.tags` to add tags when executing agents or workflows:
|
|
472
450
|
|
|
473
|
-
```ts
|
|
451
|
+
```ts
|
|
474
452
|
// With agents
|
|
475
|
-
const result = await agent.generate({
|
|
476
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
453
|
+
const result = await agent.generate("Hello", {
|
|
477
454
|
tracingOptions: {
|
|
478
455
|
tags: ["production", "experiment-v2", "user-request"],
|
|
479
456
|
},
|
|
@@ -500,9 +477,8 @@ const result = await run.start({
|
|
|
500
477
|
- **OtelBridge** - `mastra.tags` span attribute
|
|
501
478
|
- **Combinable with metadata**: You can use both `tags` and `metadata` in the same `tracingOptions`
|
|
502
479
|
|
|
503
|
-
```ts
|
|
504
|
-
const result = await agent.generate({
|
|
505
|
-
messages: [{ role: "user", content: "Analyze this" }],
|
|
480
|
+
```ts
|
|
481
|
+
const result = await agent.generate([{ role: "user", content: "Analyze this" }], {
|
|
506
482
|
tracingOptions: {
|
|
507
483
|
tags: ["production", "analytics"],
|
|
508
484
|
metadata: { userId: "user-123", experimentId: "exp-456" },
|
|
@@ -518,24 +494,75 @@ const result = await agent.generate({
|
|
|
518
494
|
- **Priority levels**: `"priority-high"`, `"priority-low"`
|
|
519
495
|
- **Experiments**: `"experiment-v1"`, `"control-group"`, `"treatment-a"`
|
|
520
496
|
|
|
497
|
+
### Hiding Sensitive Input/Output
|
|
498
|
+
|
|
499
|
+
When processing sensitive data, you may want to prevent input and output values from being logged to your observability platforms. Use `hideInput` and `hideOutput` in `tracingOptions` to exclude this data from all spans in a trace:
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
// Hide input data (e.g., user credentials, PII)
|
|
503
|
+
const result = await agent.generate([{ role: "user", content: "Process this sensitive data" }], {
|
|
504
|
+
tracingOptions: {
|
|
505
|
+
hideInput: true, // Input will be hidden from all spans
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
// Hide output data (e.g., generated secrets, confidential results)
|
|
510
|
+
const result = await agent.generate([{ role: "user", content: "Generate API keys" }], {
|
|
511
|
+
tracingOptions: {
|
|
512
|
+
hideOutput: true, // Output will be hidden from all spans
|
|
513
|
+
},
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// Hide both input and output
|
|
517
|
+
const result = await agent.generate([{ role: "user", content: "Handle confidential request" }], {
|
|
518
|
+
tracingOptions: {
|
|
519
|
+
hideInput: true,
|
|
520
|
+
hideOutput: true,
|
|
521
|
+
},
|
|
522
|
+
});
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
#### How It Works
|
|
526
|
+
|
|
527
|
+
- **Trace-wide effect**: When set on the root span, these options apply to all child spans in the trace (tool calls, model generations, etc.)
|
|
528
|
+
- **Export-time filtering**: The data is still available internally during execution but is excluded when spans are exported to observability platforms
|
|
529
|
+
- **Combinable with other options**: You can use `hideInput`/`hideOutput` alongside `tags`, `metadata`, and other `tracingOptions`
|
|
530
|
+
|
|
531
|
+
```ts
|
|
532
|
+
const result = await agent.generate([{ role: "user", content: "Sensitive operation" }], {
|
|
533
|
+
tracingOptions: {
|
|
534
|
+
hideInput: true,
|
|
535
|
+
hideOutput: true,
|
|
536
|
+
tags: ["sensitive-operation", "pii-handling"],
|
|
537
|
+
metadata: { operationType: "credential-processing" },
|
|
538
|
+
},
|
|
539
|
+
});
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
:::tip
|
|
543
|
+
|
|
544
|
+
For more granular control over sensitive data, consider using the [Sensitive Data Filter](/docs/v1/observability/tracing/processors/sensitive-data-filter) processor, which can redact specific fields (like passwords, tokens, and keys) while preserving the rest of the input/output.
|
|
545
|
+
|
|
546
|
+
:::
|
|
547
|
+
|
|
521
548
|
#### Child Spans and Metadata Extraction
|
|
522
549
|
|
|
523
550
|
When creating child spans within tools or workflow steps, you can pass the `requestContext` parameter to enable metadata extraction:
|
|
524
551
|
|
|
525
|
-
```ts
|
|
526
|
-
execute: async (
|
|
552
|
+
```ts
|
|
553
|
+
execute: async (inputData, context) => {
|
|
527
554
|
// Create child span WITH requestContext - gets metadata extraction
|
|
528
|
-
const dbSpan = tracingContext.currentSpan?.createChildSpan({
|
|
555
|
+
const dbSpan = context?.tracingContext.currentSpan?.createChildSpan({
|
|
529
556
|
type: "generic",
|
|
530
557
|
name: "database-query",
|
|
531
|
-
requestContext, // Pass to enable metadata extraction
|
|
558
|
+
requestContext: context?.requestContext, // Pass to enable metadata extraction
|
|
532
559
|
});
|
|
533
560
|
|
|
534
561
|
const results = await db.query("SELECT * FROM users");
|
|
535
562
|
dbSpan?.end({ output: results });
|
|
536
563
|
|
|
537
564
|
// Or create child span WITHOUT requestContext - no metadata extraction
|
|
538
|
-
const cacheSpan = tracingContext.currentSpan?.createChildSpan({
|
|
565
|
+
const cacheSpan = context?.tracingContext.currentSpan?.createChildSpan({
|
|
539
566
|
type: "generic",
|
|
540
567
|
name: "cache-check",
|
|
541
568
|
// No requestContext - won't extract metadata
|
|
@@ -553,10 +580,10 @@ Child spans allow you to track fine-grained operations within your workflow step
|
|
|
553
580
|
|
|
554
581
|
Create child spans inside a tool call or workflow step to track specific operations:
|
|
555
582
|
|
|
556
|
-
```ts
|
|
557
|
-
execute: async (
|
|
583
|
+
```ts
|
|
584
|
+
execute: async (inputData, context) => {
|
|
558
585
|
// Create another child span for the main database operation
|
|
559
|
-
const querySpan = tracingContext.currentSpan?.createChildSpan({
|
|
586
|
+
const querySpan = context?.tracingContext.currentSpan?.createChildSpan({
|
|
560
587
|
type: "generic",
|
|
561
588
|
name: "database-query",
|
|
562
589
|
input: { query: inputData.query },
|
|
@@ -586,19 +613,33 @@ execute: async ({ inputData, tracingContext }) => {
|
|
|
586
613
|
|
|
587
614
|
Child spans automatically inherit the trace context from their parent, maintaining the relationship hierarchy in your observability platform.
|
|
588
615
|
|
|
589
|
-
## Span
|
|
616
|
+
## Span Formatting
|
|
590
617
|
|
|
591
|
-
|
|
618
|
+
Mastra provides two ways to transform span data before it reaches your observability platform: **span processors** and **custom span formatters**. Both allow you to modify, filter, or enrich trace data, but they operate at different levels and serve different purposes.
|
|
592
619
|
|
|
593
|
-
|
|
620
|
+
| Feature | Span Processors | Custom Span Formatters |
|
|
621
|
+
| --- | --- | --- |
|
|
622
|
+
| Configuration level | Observability config | Per-exporter |
|
|
623
|
+
| Operates on | Internal `Span` object | Exported `ExportedSpan` data |
|
|
624
|
+
| Applies to | All exporters | Single exporter |
|
|
625
|
+
| Async support | No | Yes |
|
|
626
|
+
| Use case | Security, filtering, enrichment | Platform-specific formatting, async enrichment |
|
|
627
|
+
|
|
628
|
+
Use **span processors** for synchronous transformations that should apply to all exporters (like redacting sensitive data). Use **custom span formatters** when different exporters need different representations of the same data (like plain text for one platform and structured data for another), or when you need to perform asynchronous operations like fetching data from external APIs.
|
|
629
|
+
|
|
630
|
+
### Span Processors
|
|
631
|
+
|
|
632
|
+
Span processors transform, filter, or enrich trace data before it's exported. They act as a pipeline between span creation and export, enabling you to modify spans for security, compliance, or debugging purposes. Processors run once and affect all exporters.
|
|
633
|
+
|
|
634
|
+
#### Built-in Processors
|
|
594
635
|
|
|
595
636
|
- [Sensitive Data Filter](/docs/v1/observability/tracing/processors/sensitive-data-filter) redacts sensitive information. It is enabled in the default observability config.
|
|
596
637
|
|
|
597
|
-
|
|
638
|
+
#### Creating Custom Processors
|
|
598
639
|
|
|
599
640
|
You can create custom span processors by implementing the `SpanOutputProcessor` interface. Here's a simple example that converts all input text in spans to lowercase:
|
|
600
641
|
|
|
601
|
-
```ts title="src/processors/lowercase-input-processor.ts"
|
|
642
|
+
```ts title="src/processors/lowercase-input-processor.ts"
|
|
602
643
|
import type { SpanOutputProcessor, AnySpan } from "@mastra/observability";
|
|
603
644
|
|
|
604
645
|
export class LowercaseInputProcessor implements SpanOutputProcessor {
|
|
@@ -627,14 +668,211 @@ export const mastra = new Mastra({
|
|
|
627
668
|
});
|
|
628
669
|
```
|
|
629
670
|
|
|
630
|
-
Processors are executed in the order they're defined, allowing you to chain multiple transformations. Common use cases
|
|
671
|
+
Processors are executed in the order they're defined, allowing you to chain multiple transformations. Common use cases include:
|
|
631
672
|
|
|
673
|
+
- Redacting sensitive data (passwords, tokens, API keys)
|
|
632
674
|
- Adding environment-specific metadata
|
|
633
675
|
- Filtering out spans based on criteria
|
|
634
676
|
- Normalizing data formats
|
|
635
|
-
- Sampling high-volume traces
|
|
636
677
|
- Enriching spans with business context
|
|
637
678
|
|
|
679
|
+
### Custom Span Formatters
|
|
680
|
+
|
|
681
|
+
Custom span formatters transform how spans appear in specific observability platforms. Unlike span processors, formatters are configured per-exporter, allowing different formatting for different destinations. Formatters support both synchronous and asynchronous operations.
|
|
682
|
+
|
|
683
|
+
#### Use Cases
|
|
684
|
+
|
|
685
|
+
- **Extract plain text from AI SDK messages** - Convert structured message arrays to readable text
|
|
686
|
+
- **Transform input/output formats** - Customize how data appears in specific platforms
|
|
687
|
+
- **Platform-specific field mapping** - Add or remove fields based on platform requirements
|
|
688
|
+
- **Async data enrichment** - Fetch additional context from external APIs or databases
|
|
689
|
+
|
|
690
|
+
#### Configuration
|
|
691
|
+
|
|
692
|
+
Add a `customSpanFormatter` to any exporter configuration:
|
|
693
|
+
|
|
694
|
+
```ts title="src/mastra/index.ts"
|
|
695
|
+
import { BraintrustExporter } from "@mastra/braintrust";
|
|
696
|
+
import { LangfuseExporter } from "@mastra/langfuse";
|
|
697
|
+
import { SpanType } from "@mastra/core/observability";
|
|
698
|
+
import type { CustomSpanFormatter } from "@mastra/core/observability";
|
|
699
|
+
|
|
700
|
+
// Formatter that extracts plain text from AI messages
|
|
701
|
+
const plainTextFormatter: CustomSpanFormatter = (span) => {
|
|
702
|
+
if (span.type === SpanType.AGENT_RUN && Array.isArray(span.input)) {
|
|
703
|
+
const userMessage = span.input.find((m) => m.role === "user");
|
|
704
|
+
return {
|
|
705
|
+
...span,
|
|
706
|
+
input: userMessage?.content ?? span.input,
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
return span;
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
export const mastra = new Mastra({
|
|
713
|
+
observability: new Observability({
|
|
714
|
+
configs: {
|
|
715
|
+
default: {
|
|
716
|
+
serviceName: "my-service",
|
|
717
|
+
exporters: [
|
|
718
|
+
// Braintrust gets plain text formatting
|
|
719
|
+
new BraintrustExporter({
|
|
720
|
+
customSpanFormatter: plainTextFormatter,
|
|
721
|
+
}),
|
|
722
|
+
// Langfuse keeps the original structured format
|
|
723
|
+
new LangfuseExporter(),
|
|
724
|
+
],
|
|
725
|
+
},
|
|
726
|
+
},
|
|
727
|
+
}),
|
|
728
|
+
});
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
#### Chaining Multiple Formatters
|
|
732
|
+
|
|
733
|
+
Use `chainFormatters` to combine multiple formatters. Chains support both sync and async formatters:
|
|
734
|
+
|
|
735
|
+
```ts
|
|
736
|
+
import { chainFormatters } from "@mastra/observability";
|
|
737
|
+
|
|
738
|
+
const inputFormatter: CustomSpanFormatter = (span) => ({
|
|
739
|
+
...span,
|
|
740
|
+
input: extractPlainText(span.input),
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
const outputFormatter: CustomSpanFormatter = (span) => ({
|
|
744
|
+
...span,
|
|
745
|
+
output: extractPlainText(span.output),
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
const exporter = new BraintrustExporter({
|
|
749
|
+
customSpanFormatter: chainFormatters([inputFormatter, outputFormatter]),
|
|
750
|
+
});
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
#### Async Formatters
|
|
754
|
+
|
|
755
|
+
Custom span formatters support asynchronous operations, enabling use cases like fetching data from external APIs or databases to enrich your spans:
|
|
756
|
+
|
|
757
|
+
```ts
|
|
758
|
+
import type { CustomSpanFormatter } from "@mastra/core/observability";
|
|
759
|
+
|
|
760
|
+
// Async formatter that enriches spans with user data
|
|
761
|
+
const userEnrichmentFormatter: CustomSpanFormatter = async (span) => {
|
|
762
|
+
const userId = span.metadata?.userId;
|
|
763
|
+
if (!userId) return span;
|
|
764
|
+
|
|
765
|
+
// Fetch user data from your API or database
|
|
766
|
+
const userData = await fetchUserData(userId);
|
|
767
|
+
|
|
768
|
+
return {
|
|
769
|
+
...span,
|
|
770
|
+
metadata: {
|
|
771
|
+
...span.metadata,
|
|
772
|
+
userName: userData.name,
|
|
773
|
+
userEmail: userData.email,
|
|
774
|
+
department: userData.department,
|
|
775
|
+
},
|
|
776
|
+
};
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
// Async formatter that looks up additional context
|
|
780
|
+
const contextEnrichmentFormatter: CustomSpanFormatter = async (span) => {
|
|
781
|
+
if (span.type !== SpanType.AGENT_RUN) return span;
|
|
782
|
+
|
|
783
|
+
// Fetch experiment configuration
|
|
784
|
+
const experimentConfig = await getExperimentConfig(span.metadata?.experimentId);
|
|
785
|
+
|
|
786
|
+
return {
|
|
787
|
+
...span,
|
|
788
|
+
metadata: {
|
|
789
|
+
...span.metadata,
|
|
790
|
+
experimentVariant: experimentConfig?.variant,
|
|
791
|
+
experimentGroup: experimentConfig?.group,
|
|
792
|
+
},
|
|
793
|
+
};
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
// Use async formatters with an exporter
|
|
797
|
+
const exporter = new BraintrustExporter({
|
|
798
|
+
customSpanFormatter: userEnrichmentFormatter,
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
// Or chain sync and async formatters together
|
|
802
|
+
const exporter = new LangfuseExporter({
|
|
803
|
+
customSpanFormatter: chainFormatters([
|
|
804
|
+
plainTextFormatter, // sync
|
|
805
|
+
userEnrichmentFormatter, // async
|
|
806
|
+
contextEnrichmentFormatter, // async
|
|
807
|
+
]),
|
|
808
|
+
});
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
:::note
|
|
812
|
+
Async formatters add latency to span export. Keep async operations fast (under 100ms) to avoid slowing down your application. Consider using caching for frequently accessed data.
|
|
813
|
+
:::
|
|
814
|
+
|
|
815
|
+
## Serialization Options
|
|
816
|
+
|
|
817
|
+
Serialization options control how span data (input, output, and attributes) is truncated before export. This is useful when working with large payloads, deeply nested objects, or when you need to optimize trace storage.
|
|
818
|
+
|
|
819
|
+
### Configuration
|
|
820
|
+
|
|
821
|
+
Add `serializationOptions` to your observability configuration:
|
|
822
|
+
|
|
823
|
+
```ts title="src/mastra/index.ts"
|
|
824
|
+
export const mastra = new Mastra({
|
|
825
|
+
observability: new Observability({
|
|
826
|
+
configs: {
|
|
827
|
+
default: {
|
|
828
|
+
serviceName: "my-service",
|
|
829
|
+
serializationOptions: {
|
|
830
|
+
maxStringLength: 2048, // Maximum length for string values (default: 1024)
|
|
831
|
+
maxDepth: 10, // Maximum depth for nested objects (default: 6)
|
|
832
|
+
maxArrayLength: 100, // Maximum number of items in arrays (default: 50)
|
|
833
|
+
maxObjectKeys: 75, // Maximum number of keys in objects (default: 50)
|
|
834
|
+
},
|
|
835
|
+
exporters: [new DefaultExporter()],
|
|
836
|
+
},
|
|
837
|
+
},
|
|
838
|
+
}),
|
|
839
|
+
});
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
### Available Options
|
|
843
|
+
|
|
844
|
+
| Option | Default | Description |
|
|
845
|
+
| --- | --- | --- |
|
|
846
|
+
| `maxStringLength` | 1024 | Maximum length for string values. Longer strings are truncated. |
|
|
847
|
+
| `maxDepth` | 6 | Maximum depth for nested objects. Deeper levels are omitted. |
|
|
848
|
+
| `maxArrayLength` | 50 | Maximum number of items in arrays. Additional items are omitted. |
|
|
849
|
+
| `maxObjectKeys` | 50 | Maximum number of keys in objects. Additional keys are omitted. |
|
|
850
|
+
|
|
851
|
+
### Use Cases
|
|
852
|
+
|
|
853
|
+
**Increasing limits for debugging**: If your agents or tools work with large documents, API responses, or data structures, increase these limits to capture more context in your traces:
|
|
854
|
+
|
|
855
|
+
```ts
|
|
856
|
+
serializationOptions: {
|
|
857
|
+
maxStringLength: 8192, // Capture longer text content
|
|
858
|
+
maxDepth: 12, // Handle deeply nested JSON responses
|
|
859
|
+
maxArrayLength: 200, // Keep more items from large lists
|
|
860
|
+
}
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
**Reducing trace size for production**: Lower these values to reduce storage costs and improve performance when you don't need full payload visibility:
|
|
864
|
+
|
|
865
|
+
```ts
|
|
866
|
+
serializationOptions: {
|
|
867
|
+
maxStringLength: 256, // Truncate strings aggressively
|
|
868
|
+
maxDepth: 3, // Shallow object representation
|
|
869
|
+
maxArrayLength: 10, // Keep only first few items
|
|
870
|
+
maxObjectKeys: 20, // Limit object keys
|
|
871
|
+
}
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
All options are optional — if not specified, they fall back to the defaults shown above.
|
|
875
|
+
|
|
638
876
|
## Retrieving Trace IDs
|
|
639
877
|
|
|
640
878
|
When you execute agents or workflows with tracing enabled, the response includes a `traceId` that you can use to look up the full trace in your observability platform. This is useful for debugging, customer support, or correlating traces with other events in your system.
|
|
@@ -643,18 +881,14 @@ When you execute agents or workflows with tracing enabled, the response includes
|
|
|
643
881
|
|
|
644
882
|
Both `generate` and `stream` methods return the trace ID in their response:
|
|
645
883
|
|
|
646
|
-
```ts
|
|
884
|
+
```ts
|
|
647
885
|
// Using generate
|
|
648
|
-
const result = await agent.generate(
|
|
649
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
650
|
-
});
|
|
886
|
+
const result = await agent.generate("Hello");
|
|
651
887
|
|
|
652
888
|
console.log("Trace ID:", result.traceId);
|
|
653
889
|
|
|
654
890
|
// Using stream
|
|
655
|
-
const streamResult = await agent.stream(
|
|
656
|
-
messages: [{ role: "user", content: "Tell me a story" }],
|
|
657
|
-
});
|
|
891
|
+
const streamResult = await agent.stream("Tell me a story");
|
|
658
892
|
|
|
659
893
|
console.log("Trace ID:", streamResult.traceId);
|
|
660
894
|
```
|
|
@@ -663,7 +897,7 @@ console.log("Trace ID:", streamResult.traceId);
|
|
|
663
897
|
|
|
664
898
|
Workflow executions also return trace IDs:
|
|
665
899
|
|
|
666
|
-
```ts
|
|
900
|
+
```ts
|
|
667
901
|
// Create a workflow run
|
|
668
902
|
const run = await mastra.getWorkflow("myWorkflow").createRun();
|
|
669
903
|
|
|
@@ -703,7 +937,7 @@ When running Mastra agents or workflows within applications that have existing d
|
|
|
703
937
|
|
|
704
938
|
Use the `tracingOptions` parameter to specify the trace context from your parent system:
|
|
705
939
|
|
|
706
|
-
```ts
|
|
940
|
+
```ts
|
|
707
941
|
// Get trace context from your existing tracing system
|
|
708
942
|
const parentTraceId = getCurrentTraceId(); // Your tracing system
|
|
709
943
|
const parentSpanId = getCurrentSpanId(); // Your tracing system
|
|
@@ -723,7 +957,7 @@ const result = await agent.generate("Analyze this data", {
|
|
|
723
957
|
|
|
724
958
|
Integration with OpenTelemetry allows Mastra traces to appear seamlessly in your existing observability platform:
|
|
725
959
|
|
|
726
|
-
```ts
|
|
960
|
+
```ts
|
|
727
961
|
import { trace } from "@opentelemetry/api";
|
|
728
962
|
|
|
729
963
|
// Get the current OpenTelemetry span
|
|
@@ -744,7 +978,7 @@ if (spanContext) {
|
|
|
744
978
|
|
|
745
979
|
Workflows support the same pattern for trace propagation:
|
|
746
980
|
|
|
747
|
-
```ts
|
|
981
|
+
```ts
|
|
748
982
|
const workflow = mastra.getWorkflow("data-pipeline");
|
|
749
983
|
const run = await workflow.createRun();
|
|
750
984
|
|
|
@@ -775,7 +1009,7 @@ This ensures tracing never crashes your application, even with malformed input.
|
|
|
775
1009
|
|
|
776
1010
|
Here's a complete example showing trace propagation in an Express application:
|
|
777
1011
|
|
|
778
|
-
```ts
|
|
1012
|
+
```ts
|
|
779
1013
|
import { trace } from "@opentelemetry/api";
|
|
780
1014
|
import express from "express";
|
|
781
1015
|
|
|
@@ -801,6 +1035,52 @@ app.post("/api/analyze", async (req, res) => {
|
|
|
801
1035
|
|
|
802
1036
|
This creates a single distributed trace that includes both the HTTP request handling and the Mastra agent execution, viewable in your observability platform of choice.
|
|
803
1037
|
|
|
1038
|
+
## Flushing Traces in Serverless Environments
|
|
1039
|
+
|
|
1040
|
+
In serverless environments like Vercel's fluid compute, AWS Lambda, or Cloudflare Workers, runtime instances can be reused across multiple requests. The `flush()` method allows you to ensure all buffered spans are exported before the runtime terminates, without shutting down the exporter (which would prevent future exports).
|
|
1041
|
+
|
|
1042
|
+
### Using flush()
|
|
1043
|
+
|
|
1044
|
+
Call `flush()` on the observability instance to flush all exporters:
|
|
1045
|
+
|
|
1046
|
+
```ts
|
|
1047
|
+
// Get the observability instance from Mastra
|
|
1048
|
+
const observability = mastra.getObservability();
|
|
1049
|
+
|
|
1050
|
+
// Flush all buffered spans to all exporters
|
|
1051
|
+
await observability.flush();
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
### When to Use flush()
|
|
1055
|
+
|
|
1056
|
+
Use `flush()` in these scenarios:
|
|
1057
|
+
|
|
1058
|
+
- **End of serverless function execution**: Ensure spans are exported before the runtime is paused or terminated
|
|
1059
|
+
- **Before long-running operations**: Flush accumulated spans before a potentially slow operation
|
|
1060
|
+
- **Periodic flushing**: In long-running processes, periodically flush to ensure timely data availability
|
|
1061
|
+
|
|
1062
|
+
```ts
|
|
1063
|
+
// Example: Vercel serverless function
|
|
1064
|
+
export async function POST(req: Request) {
|
|
1065
|
+
const result = await agent.generate([{ role: "user", content: await req.text() }]);
|
|
1066
|
+
|
|
1067
|
+
// Ensure spans are exported before function completes
|
|
1068
|
+
const observability = mastra.getObservability();
|
|
1069
|
+
await observability.flush();
|
|
1070
|
+
|
|
1071
|
+
return Response.json(result);
|
|
1072
|
+
}
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
### flush() vs shutdown()
|
|
1076
|
+
|
|
1077
|
+
| Method | Behavior | Use Case |
|
|
1078
|
+
| --- | --- | --- |
|
|
1079
|
+
| `flush()` | Exports buffered spans, keeps exporter active | Serverless environments, periodic flushing |
|
|
1080
|
+
| `shutdown()` | Exports buffered spans, releases resources | Application shutdown, graceful termination |
|
|
1081
|
+
|
|
1082
|
+
Use `flush()` when you need to ensure data is exported but want to keep the exporter ready for future requests. Use `shutdown()` only when the application is terminating.
|
|
1083
|
+
|
|
804
1084
|
## What Gets Traced
|
|
805
1085
|
|
|
806
1086
|
Mastra automatically creates spans for:
|
|
@@ -836,7 +1116,7 @@ Mastra automatically creates spans for:
|
|
|
836
1116
|
- [Arize](/reference/v1/observability/tracing/exporters/arize) - Arize Phoenix and Arize AX integration
|
|
837
1117
|
- [Braintrust](/reference/v1/observability/tracing/exporters/braintrust) - Braintrust integration
|
|
838
1118
|
- [Langfuse](/reference/v1/observability/tracing/exporters/langfuse) - Langfuse integration
|
|
839
|
-
- [MLflow](/
|
|
1119
|
+
- [MLflow](/docs/v1/observability/tracing/exporters/otel#mlflow) - MLflow OTLP endpoint setup
|
|
840
1120
|
- [OpenTelemetry](/reference/v1/observability/tracing/exporters/otel) - OTEL-compatible platforms
|
|
841
1121
|
|
|
842
1122
|
### Bridges
|