@mastra/mcp-docs-server 0.13.24 → 0.13.25-alpha.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.
Files changed (128) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
  2. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +24 -1
  4. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +22 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
  6. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +19 -19
  7. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +21 -21
  8. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +46 -46
  9. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +19 -19
  10. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +21 -21
  11. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +21 -21
  12. package/.docs/organized/changelogs/%40mastra%2Fcore.md +104 -104
  13. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +19 -19
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +40 -40
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +33 -33
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +34 -34
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +34 -34
  18. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +59 -59
  19. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +21 -21
  20. package/.docs/organized/changelogs/%40mastra%2Fevals.md +24 -24
  21. package/.docs/organized/changelogs/%40mastra%2Flance.md +21 -21
  22. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +29 -29
  23. package/.docs/organized/changelogs/%40mastra%2Floggers.md +19 -19
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +25 -25
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +19 -19
  26. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +22 -22
  27. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +27 -27
  28. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +21 -21
  29. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +21 -21
  30. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
  31. package/.docs/organized/changelogs/%40mastra%2Fpg.md +33 -33
  32. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +19 -19
  33. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +73 -73
  34. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +20 -20
  35. package/.docs/organized/changelogs/%40mastra%2Frag.md +22 -22
  36. package/.docs/organized/changelogs/%40mastra%2Freact.md +17 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +18 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fserver.md +51 -51
  40. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +19 -19
  41. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +24 -24
  42. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +19 -19
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +19 -19
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +19 -19
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +19 -19
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +19 -19
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +20 -3
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +18 -0
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +21 -21
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +20 -20
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +20 -20
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +21 -21
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +19 -19
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +19 -19
  55. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +19 -19
  56. package/.docs/organized/changelogs/create-mastra.md +32 -32
  57. package/.docs/organized/changelogs/mastra.md +64 -64
  58. package/.docs/organized/code-examples/agent.md +0 -4
  59. package/.docs/organized/code-examples/ai-elements.md +47 -0
  60. package/.docs/organized/code-examples/heads-up-game.md +5 -5
  61. package/.docs/raw/auth/clerk.mdx +3 -3
  62. package/.docs/raw/index.mdx +1 -0
  63. package/.docs/raw/observability/ai-tracing/exporters/braintrust.mdx +81 -0
  64. package/.docs/raw/observability/ai-tracing/exporters/cloud.mdx +120 -0
  65. package/.docs/raw/observability/ai-tracing/exporters/default.mdx +168 -0
  66. package/.docs/raw/observability/ai-tracing/exporters/langfuse.mdx +121 -0
  67. package/.docs/raw/observability/ai-tracing/exporters/langsmith.mdx +88 -0
  68. package/.docs/raw/observability/ai-tracing/exporters/otel.mdx +250 -0
  69. package/.docs/raw/observability/ai-tracing/overview.mdx +565 -0
  70. package/.docs/raw/observability/ai-tracing/processors/sensitive-data-filter.mdx +274 -0
  71. package/.docs/raw/observability/{tracing.mdx → otel-tracing.mdx} +2 -2
  72. package/.docs/raw/observability/overview.mdx +66 -0
  73. package/.docs/raw/reference/agents/generate.mdx +39 -1
  74. package/.docs/raw/reference/agents/generateVNext.mdx +34 -2
  75. package/.docs/raw/reference/agents/network.mdx +35 -3
  76. package/.docs/raw/reference/auth/clerk.mdx +1 -1
  77. package/.docs/raw/reference/client-js/agents.mdx +4 -13
  78. package/.docs/raw/reference/client-js/mastra-client.mdx +10 -0
  79. package/.docs/raw/reference/client-js/observability.mdx +76 -0
  80. package/.docs/raw/reference/core/getScorer.mdx +75 -0
  81. package/.docs/raw/reference/core/getScorerByName.mdx +75 -0
  82. package/.docs/raw/reference/core/getScorers.mdx +42 -0
  83. package/.docs/raw/reference/core/mastra-class.mdx +7 -0
  84. package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +182 -0
  85. package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +234 -0
  86. package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +112 -0
  87. package/.docs/raw/reference/observability/ai-tracing/exporters/cloud-exporter.mdx +176 -0
  88. package/.docs/raw/reference/observability/ai-tracing/exporters/console-exporter.mdx +148 -0
  89. package/.docs/raw/reference/observability/ai-tracing/exporters/default-exporter.mdx +196 -0
  90. package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +116 -0
  91. package/.docs/raw/reference/observability/ai-tracing/exporters/langsmith.mdx +112 -0
  92. package/.docs/raw/reference/observability/ai-tracing/exporters/otel.mdx +355 -0
  93. package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +651 -0
  94. package/.docs/raw/reference/observability/ai-tracing/processors/sensitive-data-filter.mdx +178 -0
  95. package/.docs/raw/reference/observability/ai-tracing/span.mdx +371 -0
  96. package/.docs/raw/reference/observability/{logger.mdx → logging/pino-logger.mdx} +1 -1
  97. package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/index.mdx +6 -4
  98. package/.docs/raw/reference/scorers/create-scorer.mdx +59 -9
  99. package/.docs/raw/reference/scorers/mastra-scorer.mdx +6 -0
  100. package/.docs/raw/reference/scorers/run-experiment.mdx +216 -0
  101. package/.docs/raw/reference/streaming/ChunkType.mdx +3 -2
  102. package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +1 -1
  103. package/.docs/raw/reference/streaming/agents/stream.mdx +41 -3
  104. package/.docs/raw/reference/streaming/agents/streamVNext.mdx +34 -2
  105. package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +17 -1
  106. package/.docs/raw/reference/streaming/workflows/stream.mdx +39 -1
  107. package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +39 -1
  108. package/.docs/raw/reference/tools/create-tool.mdx +34 -1
  109. package/.docs/raw/reference/workflows/run-methods/resume.mdx +38 -0
  110. package/.docs/raw/reference/workflows/run-methods/start.mdx +38 -0
  111. package/.docs/raw/scorers/custom-scorers.mdx +16 -1
  112. package/.docs/raw/scorers/overview.mdx +28 -0
  113. package/CHANGELOG.md +15 -0
  114. package/package.json +6 -6
  115. package/.docs/raw/observability/ai-tracing.mdx +0 -597
  116. /package/.docs/raw/reference/observability/{otel-config.mdx → otel-tracing/otel-config.mdx} +0 -0
  117. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-ax.mdx +0 -0
  118. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-phoenix.mdx +0 -0
  119. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/braintrust.mdx +0 -0
  120. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/dash0.mdx +0 -0
  121. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/keywordsai.mdx +0 -0
  122. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/laminar.mdx +0 -0
  123. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langfuse.mdx +0 -0
  124. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langsmith.mdx +0 -0
  125. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langwatch.mdx +0 -0
  126. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/new-relic.mdx +0 -0
  127. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/signoz.mdx +0 -0
  128. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/traceloop.mdx +0 -0
@@ -0,0 +1,112 @@
1
+ ---
2
+ title: "BraintrustExporter | Exporters | AI Tracing | Reference"
3
+ description: Braintrust exporter for AI tracing
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # BraintrustExporter
9
+
10
+ Sends AI tracing data to Braintrust for eval and observability.
11
+
12
+ ## Constructor
13
+
14
+ ```typescript
15
+ new BraintrustExporter(config: BraintrustExporterConfig)
16
+ ```
17
+
18
+ ## BraintrustExporterConfig
19
+
20
+ ```typescript
21
+ interface BraintrustExporterConfig {
22
+ apiKey?: string;
23
+ endpoint?: string;
24
+ projectName?: string;
25
+ logLevel?: 'debug' | 'info' | 'warn' | 'error';
26
+ tuningParameters?: Record<string, any>;
27
+ }
28
+ ```
29
+
30
+ <PropertiesTable
31
+ props={[
32
+ {
33
+ name: "apiKey",
34
+ type: "string",
35
+ description: "Braintrust API key",
36
+ required: false,
37
+ },
38
+ {
39
+ name: "endpoint",
40
+ type: "string",
41
+ description: "Custom Braintrust endpoint",
42
+ required: false,
43
+ },
44
+ {
45
+ name: "projectName",
46
+ type: "string",
47
+ description: "Project name (default: 'mastra-tracing')",
48
+ required: false,
49
+ },
50
+ {
51
+ name: "logLevel",
52
+ type: "'debug' | 'info' | 'warn' | 'error'",
53
+ description: "Logger level (default: 'warn')",
54
+ required: false,
55
+ },
56
+ {
57
+ name: "tuningParameters",
58
+ type: "Record<string, any>",
59
+ description: "Tuning parameters for Braintrust",
60
+ required: false,
61
+ },
62
+ ]}
63
+ />
64
+
65
+ ## Methods
66
+
67
+ ### exportEvent
68
+
69
+ ```typescript
70
+ async exportEvent(event: AITracingEvent): Promise<void>
71
+ ```
72
+
73
+ Exports a tracing event to Braintrust.
74
+
75
+ ### export
76
+
77
+ ```typescript
78
+ async export(spans: ReadOnlyAISpan[]): Promise<void>
79
+ ```
80
+
81
+ Batch exports spans to Braintrust.
82
+
83
+ ### shutdown
84
+
85
+ ```typescript
86
+ async shutdown(): Promise<void>
87
+ ```
88
+
89
+ Flushes pending data and shuts down the client.
90
+
91
+ ## Usage
92
+
93
+ ```typescript
94
+ import { BraintrustExporter } from '@mastra/braintrust';
95
+
96
+ const exporter = new BraintrustExporter({
97
+ apiKey: process.env.BRAINTRUST_API_KEY,
98
+ projectName: 'my-ai-project',
99
+ });
100
+ ```
101
+
102
+ ## Span Type Mapping
103
+
104
+ | AI Span Type | Braintrust Type |
105
+ |--------------|-----------------|
106
+ | `LLM_GENERATION` | `llm` |
107
+ | `LLM_CHUNK` | `llm` |
108
+ | `TOOL_CALL` | `tool` |
109
+ | `MCP_TOOL_CALL` | `tool` |
110
+ | `WORKFLOW_CONDITIONAL_EVAL` | `function` |
111
+ | `WORKFLOW_WAIT_EVENT` | `function` |
112
+ | All others | `task` |
@@ -0,0 +1,176 @@
1
+ ---
2
+ title: "CloudExporter | Exporters | AI Tracing | Reference"
3
+ description: API reference for the CloudExporter
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # CloudExporter
9
+
10
+ Sends traces to Mastra Cloud for online visualization and monitoring.
11
+
12
+ ## Constructor
13
+
14
+ ```typescript
15
+ new CloudExporter(config?: CloudExporterConfig)
16
+ ```
17
+
18
+ <PropertiesTable
19
+ props={[
20
+ {
21
+ name: "config",
22
+ type: "CloudExporterConfig",
23
+ description: "Configuration options",
24
+ required: false,
25
+ },
26
+ ]}
27
+ />
28
+
29
+ ## CloudExporterConfig
30
+
31
+ ```typescript
32
+ interface CloudExporterConfig {
33
+ /** Maximum number of spans per batch. Default: 1000 */
34
+ maxBatchSize?: number;
35
+
36
+ /** Maximum wait time before flushing in milliseconds. Default: 5000 */
37
+ maxBatchWaitMs?: number;
38
+
39
+ /** Maximum retry attempts. Default: 3 */
40
+ maxRetries?: number;
41
+
42
+ /** Cloud access token (from env or config) */
43
+ accessToken?: string;
44
+
45
+ /** Cloud AI tracing endpoint */
46
+ endpoint?: string;
47
+
48
+ /** Optional logger */
49
+ logger?: IMastraLogger;
50
+ }
51
+ ```
52
+
53
+ ## Environment Variables
54
+
55
+ The exporter reads these environment variables if not provided in config:
56
+
57
+ - `MASTRA_CLOUD_ACCESS_TOKEN` - Access token for authentication
58
+ - `MASTRA_CLOUD_AI_TRACES_ENDPOINT` - Custom endpoint (defaults to `https://api.mastra.ai/ai/spans/publish`)
59
+
60
+ ## Properties
61
+
62
+ ```typescript
63
+ readonly name = 'mastra-cloud-ai-tracing-exporter';
64
+ ```
65
+
66
+ ## Methods
67
+
68
+ ### exportEvent
69
+
70
+ ```typescript
71
+ async exportEvent(event: AITracingEvent): Promise<void>
72
+ ```
73
+
74
+ Processes tracing events. Only exports SPAN_ENDED events to Cloud.
75
+
76
+ <PropertiesTable
77
+ props={[
78
+ {
79
+ name: "event",
80
+ type: "AITracingEvent",
81
+ description: "The tracing event to export",
82
+ required: true,
83
+ },
84
+ ]}
85
+ />
86
+
87
+ ### shutdown
88
+
89
+ ```typescript
90
+ async shutdown(): Promise<void>
91
+ ```
92
+
93
+ Flushes remaining events and performs cleanup.
94
+
95
+ ## Behavior
96
+
97
+ ### Authentication
98
+
99
+ If no access token is provided via config or environment variable, the exporter:
100
+ - Logs a warning with sign-up information
101
+ - Operates as a no-op (discards all events)
102
+
103
+ ### Batching
104
+
105
+ The exporter batches spans for efficient network usage:
106
+ - Flushes when batch size reaches `maxBatchSize`
107
+ - Flushes when `maxBatchWaitMs` elapsed since first span in batch
108
+ - Flushes on `shutdown()`
109
+
110
+ ### Error Handling
111
+
112
+ - Uses exponential backoff retry with `maxRetries` attempts
113
+ - Drops batches after all retries fail
114
+ - Logs errors but continues processing new events
115
+
116
+ ### Event Processing
117
+
118
+ - Only processes `SPAN_ENDED` events
119
+ - Ignores `SPAN_STARTED` and `SPAN_UPDATED` events
120
+ - Formats spans to MastraCloudSpanRecord format
121
+
122
+ ## MastraCloudSpanRecord
123
+
124
+ Internal format for cloud spans:
125
+
126
+ ```typescript
127
+ interface MastraCloudSpanRecord {
128
+ traceId: string;
129
+ spanId: string;
130
+ parentSpanId: string | null;
131
+ name: string;
132
+ spanType: string;
133
+ attributes: Record<string, any> | null;
134
+ metadata: Record<string, any> | null;
135
+ startedAt: Date;
136
+ endedAt: Date | null;
137
+ input: any;
138
+ output: any;
139
+ error: any;
140
+ isEvent: boolean;
141
+ createdAt: Date;
142
+ updatedAt: Date | null;
143
+ }
144
+ ```
145
+
146
+ ## Usage
147
+
148
+ ```typescript
149
+ import { CloudExporter } from '@mastra/core/ai-tracing';
150
+
151
+ // Uses environment variable for token
152
+ const exporter = new CloudExporter();
153
+
154
+ // Explicit configuration
155
+ const customExporter = new CloudExporter({
156
+ accessToken: 'your-token',
157
+ maxBatchSize: 500,
158
+ maxBatchWaitMs: 2000
159
+ });
160
+ ```
161
+
162
+ ## See Also
163
+
164
+ ### Documentation
165
+ - [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Complete guide
166
+ - [Exporters](/docs/observability/ai-tracing/overview#exporters) - Exporter concepts
167
+
168
+ ### Other Exporters
169
+ - [DefaultExporter](/reference/observability/ai-tracing/exporters/default-exporter) - Storage persistence
170
+ - [ConsoleExporter](/reference/observability/ai-tracing/exporters/console-exporter) - Debug output
171
+ - [Langfuse](/reference/observability/ai-tracing/exporters/langfuse) - Langfuse integration
172
+ - [Braintrust](/reference/observability/ai-tracing/exporters/braintrust) - Braintrust integration
173
+
174
+ ### Reference
175
+ - [Configuration](/reference/observability/ai-tracing/configuration) - Configuration options
176
+ - [Interfaces](/reference/observability/ai-tracing/interfaces) - Type definitions
@@ -0,0 +1,148 @@
1
+ ---
2
+ title: "ConsoleExporter | Exporters | AI Tracing | Reference"
3
+ description: API reference for the ConsoleExporter
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # ConsoleExporter
9
+
10
+ Outputs trace events to the console for debugging and development.
11
+
12
+ ## Constructor
13
+
14
+ ```typescript
15
+ new ConsoleExporter(logger?: IMastraLogger)
16
+ ```
17
+
18
+ <PropertiesTable
19
+ props={[
20
+ {
21
+ name: "logger",
22
+ type: "IMastraLogger",
23
+ description: "Logger instance to use. Falls back to ConsoleLogger with INFO level if not provided",
24
+ required: false,
25
+ },
26
+ ]}
27
+ />
28
+
29
+ ## Properties
30
+
31
+ ```typescript
32
+ readonly name = 'tracing-console-exporter';
33
+ ```
34
+
35
+ ## Methods
36
+
37
+ ### exportEvent
38
+
39
+ ```typescript
40
+ async exportEvent(event: AITracingEvent): Promise<void>
41
+ ```
42
+
43
+ Exports a tracing event to the console.
44
+
45
+ <PropertiesTable
46
+ props={[
47
+ {
48
+ name: "event",
49
+ type: "AITracingEvent",
50
+ description: "The tracing event to export",
51
+ required: true,
52
+ },
53
+ ]}
54
+ />
55
+
56
+ ### shutdown
57
+
58
+ ```typescript
59
+ async shutdown(): Promise<void>
60
+ ```
61
+
62
+ Logs shutdown message.
63
+
64
+ ## Output Format
65
+
66
+ The exporter outputs different formats based on event type:
67
+
68
+ ### SPAN_STARTED
69
+
70
+ ```
71
+ 🚀 SPAN_STARTED
72
+ Type: [span type]
73
+ Name: [span name]
74
+ ID: [span id]
75
+ Trace ID: [trace id]
76
+ Input: [formatted input]
77
+ Attributes: [formatted attributes]
78
+ ────────────────────────────────────────
79
+ ```
80
+
81
+ ### SPAN_ENDED
82
+
83
+ ```
84
+ ✅ SPAN_ENDED
85
+ Type: [span type]
86
+ Name: [span name]
87
+ ID: [span id]
88
+ Duration: [duration]ms
89
+ Trace ID: [trace id]
90
+ Input: [formatted input]
91
+ Output: [formatted output]
92
+ Error: [formatted error if present]
93
+ Attributes: [formatted attributes]
94
+ ────────────────────────────────────────
95
+ ```
96
+
97
+ ### SPAN_UPDATED
98
+
99
+ ```
100
+ 📝 SPAN_UPDATED
101
+ Type: [span type]
102
+ Name: [span name]
103
+ ID: [span id]
104
+ Trace ID: [trace id]
105
+ Input: [formatted input]
106
+ Output: [formatted output]
107
+ Error: [formatted error if present]
108
+ Updated Attributes: [formatted attributes]
109
+ ────────────────────────────────────────
110
+ ```
111
+
112
+ ## Usage
113
+
114
+ ```typescript
115
+ import { ConsoleExporter } from '@mastra/core/ai-tracing';
116
+ import { ConsoleLogger, LogLevel } from '@mastra/core/logger';
117
+
118
+ // Use default logger (INFO level)
119
+ const exporter = new ConsoleExporter();
120
+
121
+ // Use custom logger
122
+ const customLogger = new ConsoleLogger({ level: LogLevel.DEBUG });
123
+ const exporterWithLogger = new ConsoleExporter(customLogger);
124
+ ```
125
+
126
+ ## Implementation Details
127
+
128
+ - Formats attributes as JSON with 2-space indentation
129
+ - Calculates and displays span duration in milliseconds
130
+ - Handles serialization errors gracefully
131
+ - Logs unimplemented event types as warnings
132
+ - Uses 80-character separator lines between events
133
+
134
+ ## See Also
135
+
136
+ ### Documentation
137
+ - [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Complete guide
138
+ - [Exporters](/docs/observability/ai-tracing/overview#exporters) - Exporter concepts
139
+
140
+ ### Other Exporters
141
+ - [DefaultExporter](/reference/observability/ai-tracing/exporters/default-exporter) - Storage persistence
142
+ - [CloudExporter](/reference/observability/ai-tracing/exporters/cloud-exporter) - Mastra Cloud
143
+ - [Langfuse](/reference/observability/ai-tracing/exporters/langfuse) - Langfuse integration
144
+ - [Braintrust](/reference/observability/ai-tracing/exporters/braintrust) - Braintrust integration
145
+
146
+ ### Reference
147
+ - [Configuration](/reference/observability/ai-tracing/configuration) - Configuration options
148
+ - [Interfaces](/reference/observability/ai-tracing/interfaces) - Type definitions
@@ -0,0 +1,196 @@
1
+ ---
2
+ title: "DefaultExporter | Exporters | AI Tracing | Reference"
3
+ description: API reference for the DefaultExporter
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # DefaultExporter
9
+
10
+ Persists traces to Mastra's configured storage with automatic batching and retry logic.
11
+
12
+ ## Constructor
13
+
14
+ ```typescript
15
+ new DefaultExporter(config?: BatchingConfig, logger?: IMastraLogger)
16
+ ```
17
+
18
+ <PropertiesTable
19
+ props={[
20
+ {
21
+ name: "config",
22
+ type: "BatchingConfig",
23
+ description: "Batching configuration options",
24
+ required: false,
25
+ },
26
+ {
27
+ name: "logger",
28
+ type: "IMastraLogger",
29
+ description: "Logger instance. Falls back to ConsoleLogger with INFO level if not provided",
30
+ required: false,
31
+ },
32
+ ]}
33
+ />
34
+
35
+ ## BatchingConfig
36
+
37
+ ```typescript
38
+ interface BatchingConfig {
39
+ /** Maximum number of spans per batch. Default: 1000 */
40
+ maxBatchSize?: number;
41
+
42
+ /** Maximum total buffer size before emergency flush. Default: 10000 */
43
+ maxBufferSize?: number;
44
+
45
+ /** Maximum time to wait before flushing batch in milliseconds. Default: 5000 */
46
+ maxBatchWaitMs?: number;
47
+
48
+ /** Maximum number of retry attempts. Default: 4 */
49
+ maxRetries?: number;
50
+
51
+ /** Base retry delay in milliseconds (uses exponential backoff). Default: 500 */
52
+ retryDelayMs?: number;
53
+
54
+ /** Tracing strategy or 'auto' for automatic selection. Default: 'auto' */
55
+ strategy?: TracingStrategy | 'auto';
56
+ }
57
+ ```
58
+
59
+ ## TracingStrategy
60
+
61
+ ```typescript
62
+ type TracingStrategy = 'realtime' | 'batch-with-updates' | 'insert-only';
63
+ ```
64
+
65
+ ### Strategy Behaviors
66
+
67
+ - **realtime**: Immediately persists each event to storage
68
+ - **batch-with-updates**: Batches creates and updates separately, applies in order
69
+ - **insert-only**: Only processes SPAN_ENDED events, ignores updates
70
+
71
+ ## Properties
72
+
73
+ ```typescript
74
+ readonly name = 'tracing-default-exporter';
75
+ ```
76
+
77
+ ## Methods
78
+
79
+ ### __registerMastra
80
+
81
+ ```typescript
82
+ __registerMastra(mastra: Mastra): void
83
+ ```
84
+
85
+ Registers the Mastra instance. Called automatically after Mastra construction.
86
+
87
+ ### init
88
+
89
+ ```typescript
90
+ init(): void
91
+ ```
92
+
93
+ Initializes the exporter after dependencies are ready. Resolves tracing strategy based on storage capabilities.
94
+
95
+ ### exportEvent
96
+
97
+ ```typescript
98
+ async exportEvent(event: AITracingEvent): Promise<void>
99
+ ```
100
+
101
+ Processes a tracing event according to the resolved strategy.
102
+
103
+ <PropertiesTable
104
+ props={[
105
+ {
106
+ name: "event",
107
+ type: "AITracingEvent",
108
+ description: "The tracing event to export",
109
+ required: true,
110
+ },
111
+ ]}
112
+ />
113
+
114
+ ### shutdown
115
+
116
+ ```typescript
117
+ async shutdown(): Promise<void>
118
+ ```
119
+
120
+ Flushes remaining buffered events and performs cleanup.
121
+
122
+ ## Automatic Strategy Selection
123
+
124
+ When `strategy: 'auto'` (default), the exporter queries the storage adapter for its capabilities:
125
+
126
+ ```typescript
127
+ interface AITracingStrategy {
128
+ /** Strategies supported by this adapter */
129
+ supported: TracingStrategy[];
130
+
131
+ /** Preferred strategy for optimal performance */
132
+ preferred: TracingStrategy;
133
+ }
134
+ ```
135
+
136
+ The exporter will:
137
+ 1. Use the storage adapter's preferred strategy if available
138
+ 2. Fall back to the first supported strategy if preferred isn't available
139
+ 3. Log a warning if a user-specified strategy isn't supported
140
+
141
+ ## Batching Behavior
142
+
143
+ ### Flush Triggers
144
+
145
+ The buffer flushes when any of these conditions are met:
146
+ - Buffer size reaches `maxBatchSize`
147
+ - Time since first buffered event exceeds `maxBatchWaitMs`
148
+ - Buffer size reaches `maxBufferSize` (emergency flush)
149
+ - `shutdown()` is called
150
+
151
+ ### Retry Logic
152
+
153
+ Failed flushes are retried with exponential backoff:
154
+ - Retry delay: `retryDelayMs * 2^attempt`
155
+ - Maximum attempts: `maxRetries`
156
+ - Batch is dropped after all retries fail
157
+
158
+ ### Out-of-Order Handling
159
+
160
+ For `batch-with-updates` strategy:
161
+ - Tracks which spans have been created
162
+ - Rejects updates/ends for spans not yet created
163
+ - Logs warnings for out-of-order events
164
+ - Maintains sequence numbers for ordered updates
165
+
166
+ ## Usage
167
+
168
+ ```typescript
169
+ import { DefaultExporter } from '@mastra/core/ai-tracing';
170
+
171
+ // Default configuration
172
+ const exporter = new DefaultExporter();
173
+
174
+ // Custom batching configuration
175
+ const customExporter = new DefaultExporter({
176
+ maxBatchSize: 500,
177
+ maxBatchWaitMs: 2000,
178
+ strategy: 'batch-with-updates'
179
+ });
180
+ ```
181
+
182
+ ## See Also
183
+
184
+ ### Documentation
185
+ - [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Complete guide
186
+ - [Exporters](/docs/observability/ai-tracing/overview#exporters) - Exporter concepts
187
+
188
+ ### Other Exporters
189
+ - [CloudExporter](/reference/observability/ai-tracing/exporters/cloud-exporter) - Mastra Cloud
190
+ - [ConsoleExporter](/reference/observability/ai-tracing/exporters/console-exporter) - Debug output
191
+ - [Langfuse](/reference/observability/ai-tracing/exporters/langfuse) - Langfuse integration
192
+ - [Braintrust](/reference/observability/ai-tracing/exporters/braintrust) - Braintrust integration
193
+
194
+ ### Reference
195
+ - [Configuration](/reference/observability/ai-tracing/configuration) - Configuration options
196
+ - [Interfaces](/reference/observability/ai-tracing/interfaces) - Type definitions