Mastra
Stream Mastra agent traces to Sazabi for AI agent workflow observability.
Stream your Mastra agent traces directly to Sazabi for comprehensive observability of your AI agent workflows. Monitor agent executions, tool calls, and LLM interactions with real-time analysis.
About this data source
Mastra is a TypeScript framework for building AI agents and workflows. It has
native OpenTelemetry support through its built-in OtelExporter. By
configuring Mastra to export traces to Sazabi, you can:
- Monitor agent executions and decision paths
- Track tool calls and their results
- Analyze LLM interactions and token usage
- Detect agent failures and anomalies
- Use AI to investigate complex agent behavior
Prerequisites
Before you begin, make sure you have:
- A Mastra application deployed or running locally
- A Sazabi public API key (project-scoped)
Get your API key
Create a public key
Click Create API key and select Public as the key type. Public keys are scoped to a single project.
Copy the key and store it securely. You will not be able to see it again.
Setup
Set environment variables
Add the following environment variables to your Mastra application:
OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.<region>.intake.sazabi.com
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <your-api-key>"Replace <region> with your Sazabi project region (e.g., us-east-1) and
<your-api-key> with your Sazabi public API key.
Configure Mastra's OtelExporter
In your Mastra configuration, enable the OtelExporter:
import { Mastra } from "@mastra/core";
const mastra = new Mastra({
// ... your existing config
telemetry: {
exporter: "otel",
},
});Mastra's native OpenTelemetry support means you don't need to set up the OTEL SDK manually.
Deploy your application
Deploy your Mastra application with the new configuration. Traces will begin flowing to Sazabi when agents execute.
What gets captured
Mastra's OtelExporter captures:
- Agent executions: Start, completion, and failure events
- Tool calls: Each tool invocation with inputs and outputs
- LLM calls: Model requests, responses, and token usage
- Workflow steps: Individual steps in multi-step workflows
- Error details: Stack traces and error metadata
Verifying traces are flowing
Once configured, verify that traces are flowing to Sazabi:
-
Run an agent: Execute one of your Mastra agents.
-
Ask the assistant: Open a thread in Sazabi and ask "Show me recent Mastra agent traces" or "What tool calls did my agents make today?"
Troubleshooting
Traces not appearing in Sazabi
- Verify environment variables are set correctly
- Check that the
telemetry.exporteris set to"otel"in your Mastra config - Ensure the endpoint URL includes the correct region
- Run an agent to generate traces
401 Unauthorized errors
- Your API key may be invalid or expired
- Verify the OTEL_EXPORTER_OTLP_HEADERS format
- Create a new public API key in Settings > API Keys
Missing tool or LLM data
Verify your Mastra version supports full telemetry export. Update to the latest version if needed.