The Respan Mastra integration enables tracing and monitoring of Mastra-powered AI applications. Configure a custom OpenTelemetry exporter to send traces to the Respan platform for full workflow visibility.
Traces and performance metrics appear in the Respan dashboard after successful configuration. Monitor agent interactions, track token usage, and analyze execution patterns across your Mastra workflows.
Install the project dependencies and configure environment variables: OPENAI_API_KEY, KEYWORDSAI_API_KEY, and KEYWORDSAI_BASE_URL.
In your Mastra configuration, set the telemetry export type to custom and provide the KeywordsAIExporter. Enable telemetry and set a service name for identification.
Run mastra dev to start the development server. Traces and metrics appear in the Respan dashboard automatically.
typescript
// src/mastra/index.ts
import { KeywordsAIExporter } from "@keywordsai/exporter";
export const mastra = new Mastra({
telemetry: {
serviceName: "my-mastra-app",
enabled: true,
export: {
type: "custom",
exporter: new KeywordsAIExporter({
apiKey: process.env.KEYWORDSAI_API_KEY,
baseUrl: process.env.KEYWORDSAI_BASE_URL,
}),
},
},
});