Cloud Exporter
The CloudExporter
sends traces to Mastra Cloud for centralized monitoring and team collaboration. It’s automatically enabled when using the default observability configuration with a valid access token.
When to Use CloudExporter
CloudExporter is ideal for:
- Production monitoring - Centralized trace visualization
- Team collaboration - Share traces across your organization
- Advanced analytics - Insights and performance metrics
- Zero maintenance - No infrastructure to manage
Configuration
Prerequisites
- Mastra Cloud Account: Sign up at cloud.mastra.aiÂ
- Access Token: Generate in Mastra Cloud → Settings → API Tokens
- Environment Variables: Set your credentials:
.env
MASTRA_CLOUD_ACCESS_TOKEN=mst_xxxxxxxxxxxxxxxx
Basic Setup
src/mastra/index.ts
import { Mastra } from "@mastra/core";
import { CloudExporter } from "@mastra/core/ai-tracing";
export const mastra = new Mastra({
observability: {
configs: {
production: {
serviceName: 'my-service',
exporters: [
new CloudExporter(), // Uses MASTRA_CLOUD_ACCESS_TOKEN env var
],
},
},
},
});
Automatic Configuration
When using the default observability configuration, CloudExporter is automatically included if the access token is set:
export const mastra = new Mastra({
observability: {
default: { enabled: true }, // Automatically includes CloudExporter if token exists
},
});
Complete Configuration
new CloudExporter({
// Optional - defaults to env var
accessToken: process.env.MASTRA_CLOUD_ACCESS_TOKEN,
// Optional - for self-hosted Mastra Cloud
endpoint: 'https://cloud.your-domain.com',
// Batching configuration
maxBatchSize: 1000, // Max spans per batch
maxBatchWaitMs: 5000, // Max wait before sending batch
// Diagnostic logging
logLevel: 'info', // debug | info | warn | error
})
Viewing Traces
Mastra Cloud Dashboard
- Navigate to cloud.mastra.aiÂ
- Select your project
- Go to Observability → Traces
- Use filters to find specific traces:
- Service name
- Time range
- Trace ID
- Error status
Features
- Trace Timeline - Visual execution flow
- Span Details - Inputs, outputs, metadata
- Performance Metrics - Latency, token usage
- Team Collaboration - Share trace links
Performance
CloudExporter uses intelligent batching to optimize network usage. Traces are buffered and sent in batches, reducing overhead while maintaining near real-time visibility.
Batching Behavior
- Traces are batched up to
maxBatchSize
(default: 1000) - Batches are sent when full or after
maxBatchWaitMs
(default: 5 seconds) - Failed batches are retried with exponential backoff
- Graceful degradation if Mastra Cloud is unreachable