@mastra/mcp-docs-server 1.1.35-alpha.8 → 1.1.36-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.
- package/.docs/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +48 -4
- package/.docs/docs/agents/background-tasks.md +62 -2
- package/.docs/docs/agents/processors.md +9 -1
- package/.docs/docs/agents/response-caching.md +148 -0
- package/.docs/docs/agents/signals.md +151 -0
- package/.docs/docs/agents/using-tools.md +8 -0
- package/.docs/docs/browser/agent-browser.md +15 -0
- package/.docs/docs/browser/stagehand.md +25 -1
- package/.docs/docs/deployment/cloud-providers.md +1 -1
- package/.docs/docs/deployment/overview.md +6 -5
- package/.docs/docs/editor/tools.md +1 -1
- package/.docs/docs/index.md +2 -2
- package/.docs/docs/mastra-platform/configuration.md +22 -6
- package/.docs/docs/mastra-platform/observability.md +99 -0
- package/.docs/docs/mastra-platform/overview.md +12 -55
- package/.docs/{guides/deployment/mastra-platform.md → docs/mastra-platform/server.md} +30 -37
- package/.docs/docs/mastra-platform/studio.md +81 -0
- package/.docs/docs/memory/observational-memory.md +61 -13
- package/.docs/docs/memory/semantic-recall.md +68 -6
- package/.docs/docs/observability/logging.md +2 -2
- package/.docs/docs/observability/metrics/overview.md +4 -4
- package/.docs/docs/observability/overview.md +15 -10
- package/.docs/docs/observability/tracing/bridges/otel.md +25 -0
- package/.docs/docs/observability/tracing/exporters/arize.md +5 -5
- package/.docs/docs/observability/tracing/exporters/braintrust.md +37 -0
- package/.docs/docs/observability/tracing/exporters/langfuse.md +21 -0
- package/.docs/docs/observability/tracing/exporters/{cloud.md → mastra-platform.md} +35 -33
- package/.docs/docs/observability/tracing/exporters/{default.md → mastra-storage.md} +56 -19
- package/.docs/docs/observability/tracing/exporters/otel.md +79 -2
- package/.docs/docs/observability/tracing/overview.md +30 -29
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +6 -6
- package/.docs/docs/server/mastra-server.md +30 -19
- package/.docs/docs/studio/deployment.md +1 -37
- package/.docs/docs/studio/observability.md +31 -26
- package/.docs/docs/studio/overview.md +8 -2
- package/.docs/docs/voice/overview.md +84 -0
- package/.docs/docs/workflows/suspend-and-resume.md +28 -1
- package/.docs/guides/deployment/inngest.md +23 -0
- package/.docs/guides/getting-started/quickstart.md +4 -4
- package/.docs/guides/migrations/mastra-cloud.md +12 -12
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +19 -17
- package/.docs/models/gateways/netlify.md +2 -1
- package/.docs/models/gateways/openrouter.md +4 -1
- package/.docs/models/gateways/vercel.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +1 -1
- package/.docs/models/providers/alibaba.md +1 -1
- package/.docs/models/providers/chutes.md +23 -54
- package/.docs/models/providers/claudinio.md +71 -0
- package/.docs/models/providers/databricks.md +96 -0
- package/.docs/models/providers/deepinfra.md +3 -1
- package/.docs/models/providers/deepseek.md +3 -1
- package/.docs/models/providers/digitalocean.md +9 -2
- package/.docs/models/providers/firepass.md +71 -0
- package/.docs/models/providers/google.md +4 -3
- package/.docs/models/providers/kilo.md +6 -4
- package/.docs/models/providers/llmgateway.md +8 -2
- package/.docs/models/providers/nebius.md +37 -55
- package/.docs/models/providers/novita-ai.md +5 -5
- package/.docs/models/providers/nvidia.md +59 -49
- package/.docs/models/providers/ollama-cloud.md +1 -1
- package/.docs/models/providers/openai.md +2 -0
- package/.docs/models/providers/opencode.md +44 -43
- package/.docs/models/providers/poe.md +4 -1
- package/.docs/models/providers/sarvam.md +72 -0
- package/.docs/models/providers/wafer.ai.md +4 -5
- package/.docs/models/providers/xiaomi-token-plan-ams.md +6 -5
- package/.docs/models/providers/xiaomi-token-plan-cn.md +6 -5
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +6 -5
- package/.docs/models/providers.md +4 -1
- package/.docs/reference/agents/agent.md +85 -0
- package/.docs/reference/browser/agent-browser.md +37 -11
- package/.docs/reference/browser/stagehand-browser.md +35 -9
- package/.docs/reference/cli/create-mastra.md +6 -0
- package/.docs/reference/cli/mastra.md +63 -15
- package/.docs/reference/client-js/agents.md +115 -1
- package/.docs/reference/client-js/responses.md +4 -0
- package/.docs/reference/configuration.md +6 -6
- package/.docs/reference/editor/tool-provider.md +3 -3
- package/.docs/reference/harness/harness-class.md +22 -9
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/memory/observational-memory.md +11 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +2 -4
- package/.docs/reference/observability/tracing/bridges/datadog.md +2 -2
- package/.docs/reference/observability/tracing/bridges/otel.md +26 -4
- package/.docs/reference/observability/tracing/configuration.md +6 -3
- package/.docs/reference/observability/tracing/exporters/arize.md +1 -1
- package/.docs/reference/observability/tracing/exporters/braintrust.md +2 -0
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +5 -3
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +2 -2
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +7 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +263 -0
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +194 -0
- package/.docs/reference/observability/tracing/exporters/otel.md +12 -8
- package/.docs/reference/observability/tracing/instances.md +2 -2
- package/.docs/reference/observability/tracing/interfaces.md +37 -2
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +22 -0
- package/.docs/reference/observability/tracing/span-filtering.md +2 -2
- package/.docs/reference/processors/prefill-error-handler.md +3 -3
- package/.docs/reference/processors/response-cache.md +114 -0
- package/.docs/reference/processors/tool-call-filter.md +28 -0
- package/.docs/reference/storage/clickhouse.md +8 -8
- package/.docs/reference/storage/cloudflare-d1.md +1 -1
- package/.docs/reference/storage/cloudflare.md +1 -1
- package/.docs/reference/storage/composite.md +1 -1
- package/.docs/reference/storage/convex.md +1 -1
- package/.docs/reference/storage/dsql.md +428 -0
- package/.docs/reference/storage/duckdb.md +3 -3
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/lance.md +1 -1
- package/.docs/reference/storage/libsql.md +1 -1
- package/.docs/reference/storage/postgresql.md +1 -1
- package/.docs/reference/storage/upstash.md +1 -1
- package/.docs/reference/streaming/ChunkType.md +44 -0
- package/.docs/reference/tools/brightdata.md +167 -0
- package/.docs/reference/tools/create-tool.md +46 -0
- package/.docs/reference/voice/inworld.md +133 -0
- package/.docs/reference/workflows/workflow-state-reader.md +113 -0
- package/CHANGELOG.md +113 -0
- package/package.json +6 -6
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# MastraPlatformExporter
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/observability@1.12.0`. Earlier releases (`@mastra/observability@1.8.0` through `1.11.x`) export the same exporter as the deprecated `CloudExporter`.
|
|
4
|
+
|
|
5
|
+
Sends tracing spans, logs, metrics, scores, and feedback to the Mastra platform for online visualization and monitoring.
|
|
6
|
+
|
|
7
|
+
> **Note:** `MastraPlatformExporter` was previously called `CloudExporter`. The original `CloudExporter` class is still exported from `@mastra/observability` so existing imports keep working, but it is deprecated and will be removed in a future major version. New code should use `MastraPlatformExporter`.
|
|
8
|
+
|
|
9
|
+
## Constructor
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
new MastraPlatformExporter(config?: MastraPlatformExporterConfig)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## `MastraPlatformExporterConfig`
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
interface MastraPlatformExporterConfig extends BaseExporterConfig {
|
|
19
|
+
/** Maximum number of buffered events per batch (spans, logs, metrics, scores, feedback). Default: 1000 */
|
|
20
|
+
maxBatchSize?: number
|
|
21
|
+
|
|
22
|
+
/** Maximum wait time before flushing in milliseconds. Default: 5000 */
|
|
23
|
+
maxBatchWaitMs?: number
|
|
24
|
+
|
|
25
|
+
/** Maximum retry attempts. Default: 3 */
|
|
26
|
+
maxRetries?: number
|
|
27
|
+
|
|
28
|
+
/** Mastra Observability access token (from env or config) */
|
|
29
|
+
accessToken?: string
|
|
30
|
+
|
|
31
|
+
/** Project ID for project-scoped collector routes (letters, numbers, hyphens, underscores) */
|
|
32
|
+
projectId?: string
|
|
33
|
+
|
|
34
|
+
/** Base observability endpoint */
|
|
35
|
+
endpoint?: string
|
|
36
|
+
|
|
37
|
+
/** Explicit traces endpoint override */
|
|
38
|
+
tracesEndpoint?: string
|
|
39
|
+
|
|
40
|
+
/** Explicit logs endpoint override */
|
|
41
|
+
logsEndpoint?: string
|
|
42
|
+
|
|
43
|
+
/** Explicit metrics endpoint override */
|
|
44
|
+
metricsEndpoint?: string
|
|
45
|
+
|
|
46
|
+
/** Explicit scores endpoint override */
|
|
47
|
+
scoresEndpoint?: string
|
|
48
|
+
|
|
49
|
+
/** Explicit feedback endpoint override */
|
|
50
|
+
feedbackEndpoint?: string
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Extends `BaseExporterConfig`, which includes:
|
|
55
|
+
|
|
56
|
+
- `logger?: IMastraLogger` - Logger instance
|
|
57
|
+
- `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: INFO)
|
|
58
|
+
|
|
59
|
+
## Environment variables
|
|
60
|
+
|
|
61
|
+
The exporter reads these environment variables if not provided in config:
|
|
62
|
+
|
|
63
|
+
- `MASTRA_PLATFORM_ACCESS_TOKEN` - Authentication token for `MastraPlatformExporter` requests
|
|
64
|
+
- `MASTRA_PROJECT_ID` - Project ID to use when deriving project-scoped collector routes such as `/projects/:projectId/ai/spans/publish`
|
|
65
|
+
- `MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT` - Observability endpoint override. Pass either a base origin or a full traces publish URL. Defaults to `https://observability.mastra.ai` in `@mastra/observability@1.9.2` and later
|
|
66
|
+
|
|
67
|
+
## Properties
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
readonly name = 'mastra-platform-exporter';
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The deprecated `CloudExporter` class continues to use `'mastra-cloud-observability-exporter'` as its `name` for backward compatibility.
|
|
74
|
+
|
|
75
|
+
## Methods
|
|
76
|
+
|
|
77
|
+
### `exportTracingEvent`
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
async exportTracingEvent(event: TracingEvent): Promise<void>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Processes tracing events for export to the Mastra platform.
|
|
84
|
+
|
|
85
|
+
Only `SPAN_ENDED` tracing events are exported. `SPAN_STARTED` and `SPAN_UPDATED` are ignored. Matching spans are buffered and uploaded to the traces endpoint on the next flush.
|
|
86
|
+
|
|
87
|
+
**Returns:** `Promise<void>` after the tracing event has been accepted for buffering or ignored.
|
|
88
|
+
|
|
89
|
+
### `onLogEvent`
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
async onLogEvent(event: LogEvent): Promise<void>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Processes log signals for export.
|
|
96
|
+
|
|
97
|
+
Every `LogEvent` passed to this handler is buffered and exported to the logs endpoint derived from the configured base endpoint. Unlike tracing, there is no additional event-status filtering at the `MastraPlatformExporter` level. If the exporter is disabled, this method becomes a no-op.
|
|
98
|
+
|
|
99
|
+
**Returns:** `Promise<void>` after the log event has been accepted for buffering.
|
|
100
|
+
|
|
101
|
+
### `onMetricEvent`
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
async onMetricEvent(event: MetricEvent): Promise<void>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Processes metric signals for export.
|
|
108
|
+
|
|
109
|
+
Every `MetricEvent` passed to this handler is buffered and exported to the metrics endpoint derived from the configured base endpoint. There is no additional filtering by metric subtype or status inside `MastraPlatformExporter`; the exporter forwards every metric event it receives unless it is disabled.
|
|
110
|
+
|
|
111
|
+
**Returns:** `Promise<void>` after the metric event has been accepted for buffering.
|
|
112
|
+
|
|
113
|
+
### `onScoreEvent`
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
async onScoreEvent(event: ScoreEvent): Promise<void>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Processes score signals for export.
|
|
120
|
+
|
|
121
|
+
Every `ScoreEvent` passed to this handler is buffered and exported to the scores endpoint derived from the configured base endpoint. There is no extra filtering at the exporter layer beyond the disabled-exporter check, so all score events received by this method are forwarded.
|
|
122
|
+
|
|
123
|
+
**Returns:** `Promise<void>` after the score event has been accepted for buffering.
|
|
124
|
+
|
|
125
|
+
### `onFeedbackEvent`
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
async onFeedbackEvent(event: FeedbackEvent): Promise<void>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Processes feedback signals for export.
|
|
132
|
+
|
|
133
|
+
Every `FeedbackEvent` passed to this handler is buffered and exported to the feedback endpoint derived from the configured base endpoint. There is no feedback-type filtering inside `MastraPlatformExporter`; all feedback events received here are forwarded unless the exporter is disabled.
|
|
134
|
+
|
|
135
|
+
**Returns:** `Promise<void>` after the feedback event has been accepted for buffering.
|
|
136
|
+
|
|
137
|
+
### flush
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
async flush(): Promise<void>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Force flushes any buffered events to the Mastra platform without shutting down the exporter. Useful in serverless environments where you need to ensure spans are exported before the runtime terminates.
|
|
144
|
+
|
|
145
|
+
### shutdown
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
async shutdown(): Promise<void>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Flushes remaining events and performs cleanup.
|
|
152
|
+
|
|
153
|
+
## Behavior
|
|
154
|
+
|
|
155
|
+
### Authentication
|
|
156
|
+
|
|
157
|
+
If no access token is provided via config or environment variable, the exporter:
|
|
158
|
+
|
|
159
|
+
- Logs a warning with sign-up information
|
|
160
|
+
- Operates as a no-op (discards all events)
|
|
161
|
+
|
|
162
|
+
### Batching
|
|
163
|
+
|
|
164
|
+
The exporter batches tracing spans, logs, metrics, scores, and feedback for efficient network usage:
|
|
165
|
+
|
|
166
|
+
- Flushes when total buffered event count reaches `maxBatchSize`
|
|
167
|
+
- Flushes when `maxBatchWaitMs` elapsed since the first buffered signal in the batch
|
|
168
|
+
- Flushes on `shutdown()`
|
|
169
|
+
|
|
170
|
+
### Error handling
|
|
171
|
+
|
|
172
|
+
- Uses exponential backoff retry with `maxRetries` attempts
|
|
173
|
+
- Drops batches after all retries fail
|
|
174
|
+
- Logs errors but continues processing new events
|
|
175
|
+
|
|
176
|
+
Errors raised by `MastraPlatformExporter` use the `MASTRA_PLATFORM_EXPORTER_*` `id` prefix. The deprecated `CloudExporter` continues to emit `CLOUD_EXPORTER_*` `id`s.
|
|
177
|
+
|
|
178
|
+
### Endpoint routing
|
|
179
|
+
|
|
180
|
+
- Base origins derive signal endpoints automatically
|
|
181
|
+
- Without `projectId`, derived routes use `/ai/{signal}/publish`
|
|
182
|
+
- With `projectId` or `MASTRA_PROJECT_ID`, derived routes use `/projects/:projectId/ai/{signal}/publish`
|
|
183
|
+
- Explicit full publish URLs are used as-is, even when `projectId` is configured
|
|
184
|
+
|
|
185
|
+
### Signal Processing
|
|
186
|
+
|
|
187
|
+
- `exportTracingEvent()` only exports `SPAN_ENDED` tracing events
|
|
188
|
+
- `onLogEvent()`, `onMetricEvent()`, `onScoreEvent()`, and `onFeedbackEvent()` buffer every event they receive for their respective signal type
|
|
189
|
+
- All supported signal batches are uploaded to their matching publish endpoints during `flush()` and `shutdown()`
|
|
190
|
+
|
|
191
|
+
## Span wire format
|
|
192
|
+
|
|
193
|
+
The shape of each span sent to Mastra platform is documented here for reference only — it is not exported from `@mastra/observability` and should not be imported. The exporter spreads the original `AnyExportedSpan` (so the source field names are preserved) and layers a small set of platform-friendly aliases on top:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
type MastraPlatformSpanRecord = AnyExportedSpan & {
|
|
197
|
+
// Aliases derived from the source span
|
|
198
|
+
spanId: string // alias for span.id
|
|
199
|
+
spanType: string // alias for span.type
|
|
200
|
+
startedAt: Date // alias for span.startTime
|
|
201
|
+
endedAt: Date | null // alias for span.endTime ?? null
|
|
202
|
+
error: AnyExportedSpan['errorInfo'] | null
|
|
203
|
+
|
|
204
|
+
// Stamped at export time
|
|
205
|
+
createdAt: Date
|
|
206
|
+
updatedAt: Date | null
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The spread `AnyExportedSpan` also carries the original `id`, `type`, `name`, `traceId`, `parentSpanId`, `isRootSpan`, `isEvent`, `startTime`, `endTime`, `entityType`, `entityId`, `entityName`, `tags`, `attributes`, `metadata`, `input`, `output`, and `errorInfo`. See [Interfaces](https://mastra.ai/reference/observability/tracing/interfaces) for `AnyExportedSpan`.
|
|
211
|
+
|
|
212
|
+
## Usage
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { MastraPlatformExporter } from '@mastra/observability'
|
|
216
|
+
|
|
217
|
+
// Uses environment variable for token
|
|
218
|
+
const exporter = new MastraPlatformExporter()
|
|
219
|
+
|
|
220
|
+
// Explicit configuration
|
|
221
|
+
const customExporter = new MastraPlatformExporter({
|
|
222
|
+
accessToken: 'your-token',
|
|
223
|
+
projectId: 'project_123',
|
|
224
|
+
maxBatchSize: 500,
|
|
225
|
+
maxBatchWaitMs: 2000,
|
|
226
|
+
logLevel: 'debug',
|
|
227
|
+
})
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Migrating from `CloudExporter`
|
|
231
|
+
|
|
232
|
+
The two classes share the same constructor signature, environment variables, and behavior. To migrate, replace the import and constructor:
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
// Before
|
|
236
|
+
import { CloudExporter } from '@mastra/observability'
|
|
237
|
+
const exporter = new CloudExporter()
|
|
238
|
+
|
|
239
|
+
// After
|
|
240
|
+
import { MastraPlatformExporter } from '@mastra/observability'
|
|
241
|
+
const exporter = new MastraPlatformExporter()
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
The original `CloudExporter` is preserved unchanged so dashboards or alert rules that match the previous `CLOUD_EXPORTER_*` error IDs or `mastra-cloud-observability-exporter` exporter name keep working until you migrate.
|
|
245
|
+
|
|
246
|
+
## See also
|
|
247
|
+
|
|
248
|
+
### Documentation
|
|
249
|
+
|
|
250
|
+
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview): Complete guide
|
|
251
|
+
- [Exporters](https://mastra.ai/docs/observability/tracing/overview): Exporter concepts
|
|
252
|
+
|
|
253
|
+
### Other Exporters
|
|
254
|
+
|
|
255
|
+
- [MastraStorageExporter](https://mastra.ai/reference/observability/tracing/exporters/mastra-storage-exporter): Storage persistence
|
|
256
|
+
- [ConsoleExporter](https://mastra.ai/reference/observability/tracing/exporters/console-exporter): Debug output
|
|
257
|
+
- [Langfuse](https://mastra.ai/reference/observability/tracing/exporters/langfuse): Langfuse integration
|
|
258
|
+
- [Braintrust](https://mastra.ai/reference/observability/tracing/exporters/braintrust): Braintrust integration
|
|
259
|
+
|
|
260
|
+
### Reference
|
|
261
|
+
|
|
262
|
+
- [Configuration](https://mastra.ai/reference/observability/tracing/configuration): Configuration options
|
|
263
|
+
- [Interfaces](https://mastra.ai/reference/observability/tracing/interfaces): Type definitions
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# MastraStorageExporter
|
|
2
|
+
|
|
3
|
+
Persists traces to Mastra's configured storage with automatic batching and retry logic.
|
|
4
|
+
|
|
5
|
+
> **Note:** `MastraStorageExporter` was previously called `DefaultExporter`. The original `DefaultExporter` class is still exported from `@mastra/observability` so existing imports keep working, but it is deprecated and will be removed in a future major version. New code should use `MastraStorageExporter`.
|
|
6
|
+
|
|
7
|
+
## Constructor
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
new MastraStorageExporter(config?: MastraStorageExporterConfig)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## `MastraStorageExporterConfig`
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
interface MastraStorageExporterConfig extends BaseExporterConfig {
|
|
17
|
+
/** Maximum number of spans per batch. Default: 1000 */
|
|
18
|
+
maxBatchSize?: number
|
|
19
|
+
|
|
20
|
+
/** Maximum total buffer size before emergency flush. Default: 10000 */
|
|
21
|
+
maxBufferSize?: number
|
|
22
|
+
|
|
23
|
+
/** Maximum time to wait before flushing batch in milliseconds. Default: 5000 */
|
|
24
|
+
maxBatchWaitMs?: number
|
|
25
|
+
|
|
26
|
+
/** Maximum number of retry attempts. Default: 4 */
|
|
27
|
+
maxRetries?: number
|
|
28
|
+
|
|
29
|
+
/** Base retry delay in milliseconds (uses exponential backoff). Default: 500 */
|
|
30
|
+
retryDelayMs?: number
|
|
31
|
+
|
|
32
|
+
/** Tracing storage strategy or 'auto' for automatic selection. Default: 'auto' */
|
|
33
|
+
strategy?: TracingStorageStrategy | 'auto'
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Extends `BaseExporterConfig`, which includes:
|
|
38
|
+
|
|
39
|
+
- `logger?: IMastraLogger` - Logger instance
|
|
40
|
+
- `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: INFO)
|
|
41
|
+
|
|
42
|
+
## `TracingStorageStrategy`
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
type TracingStorageStrategy = 'realtime' | 'batch-with-updates' | 'insert-only'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Strategy Behaviors
|
|
49
|
+
|
|
50
|
+
- **realtime**: Immediately persists each event to storage
|
|
51
|
+
- **batch-with-updates**: Batches creates and updates separately, applies in order
|
|
52
|
+
- **insert-only**: Only processes SPAN\_ENDED events, ignores updates
|
|
53
|
+
|
|
54
|
+
## Properties
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
readonly name = 'mastra-storage-exporter';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The deprecated `DefaultExporter` class continues to use `'mastra-default-observability-exporter'` as its `name` for backward compatibility.
|
|
61
|
+
|
|
62
|
+
## Methods
|
|
63
|
+
|
|
64
|
+
### init
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
init(options: InitExporterOptions): void
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Initializes the exporter after dependencies are ready. Resolves tracing strategy based on storage capabilities.
|
|
71
|
+
|
|
72
|
+
### `exportTracingEvent`
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
async exportTracingEvent(event: TracingEvent): Promise<void>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Processes a tracing event according to the resolved strategy.
|
|
79
|
+
|
|
80
|
+
### flush
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
async flush(): Promise<void>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Force flushes any buffered events to storage without shutting down the exporter. Useful in serverless environments where you need to ensure spans are exported before the runtime terminates.
|
|
87
|
+
|
|
88
|
+
### shutdown
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
async shutdown(): Promise<void>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Flushes remaining buffered events and performs cleanup.
|
|
95
|
+
|
|
96
|
+
## Automatic strategy selection
|
|
97
|
+
|
|
98
|
+
When `strategy: 'auto'` (default), the exporter queries the storage adapter for its capabilities:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
interface TracingStrategy {
|
|
102
|
+
/** Strategies supported by this adapter */
|
|
103
|
+
supported: TracingStorageStrategy[]
|
|
104
|
+
|
|
105
|
+
/** Preferred strategy for optimal performance */
|
|
106
|
+
preferred: TracingStorageStrategy
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The exporter will:
|
|
111
|
+
|
|
112
|
+
1. Use the storage adapter's preferred strategy if available
|
|
113
|
+
2. Fall back to the first supported strategy if preferred isn't available
|
|
114
|
+
3. Log a warning if a user-specified strategy isn't supported
|
|
115
|
+
|
|
116
|
+
## Batching behavior
|
|
117
|
+
|
|
118
|
+
### Flush Triggers
|
|
119
|
+
|
|
120
|
+
The buffer flushes when any of these conditions are met:
|
|
121
|
+
|
|
122
|
+
- Buffer size reaches `maxBatchSize`
|
|
123
|
+
- Time since first buffered event exceeds `maxBatchWaitMs`
|
|
124
|
+
- Buffer size reaches `maxBufferSize` (emergency flush)
|
|
125
|
+
- `shutdown()` is called
|
|
126
|
+
|
|
127
|
+
### Retry Logic
|
|
128
|
+
|
|
129
|
+
Failed flushes are retried with exponential backoff:
|
|
130
|
+
|
|
131
|
+
- Retry delay: `retryDelayMs * 2^attempt`
|
|
132
|
+
- Maximum attempts: `maxRetries`
|
|
133
|
+
- Batch is dropped after all retries fail
|
|
134
|
+
|
|
135
|
+
### Out-of-Order Handling
|
|
136
|
+
|
|
137
|
+
For `batch-with-updates` strategy:
|
|
138
|
+
|
|
139
|
+
- Tracks which spans have been created
|
|
140
|
+
- Rejects updates/ends for spans not yet created
|
|
141
|
+
- Logs warnings for out-of-order events
|
|
142
|
+
- Maintains sequence numbers for ordered updates
|
|
143
|
+
|
|
144
|
+
## Usage
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { MastraStorageExporter } from '@mastra/observability'
|
|
148
|
+
|
|
149
|
+
// Default configuration
|
|
150
|
+
const exporter = new MastraStorageExporter()
|
|
151
|
+
|
|
152
|
+
// Custom batching configuration
|
|
153
|
+
const customExporter = new MastraStorageExporter({
|
|
154
|
+
maxBatchSize: 500,
|
|
155
|
+
maxBatchWaitMs: 2000,
|
|
156
|
+
strategy: 'batch-with-updates',
|
|
157
|
+
logLevel: 'debug',
|
|
158
|
+
})
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Migrating from `DefaultExporter`
|
|
162
|
+
|
|
163
|
+
The two classes share the same constructor signature and behavior. To migrate, replace the import and constructor:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
// Before
|
|
167
|
+
import { DefaultExporter } from '@mastra/observability'
|
|
168
|
+
const exporter = new DefaultExporter()
|
|
169
|
+
|
|
170
|
+
// After
|
|
171
|
+
import { MastraStorageExporter } from '@mastra/observability'
|
|
172
|
+
const exporter = new MastraStorageExporter()
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The original `DefaultExporter` is preserved unchanged so dashboards or alert rules that match the previous `mastra-default-observability-exporter` exporter name keep working until you migrate.
|
|
176
|
+
|
|
177
|
+
## See also
|
|
178
|
+
|
|
179
|
+
### Documentation
|
|
180
|
+
|
|
181
|
+
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview): Complete guide
|
|
182
|
+
- [Exporters](https://mastra.ai/docs/observability/tracing/overview): Exporter concepts
|
|
183
|
+
|
|
184
|
+
### Other Exporters
|
|
185
|
+
|
|
186
|
+
- [MastraPlatformExporter](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter): Mastra platform
|
|
187
|
+
- [ConsoleExporter](https://mastra.ai/reference/observability/tracing/exporters/console-exporter): Debug output
|
|
188
|
+
- [Langfuse](https://mastra.ai/reference/observability/tracing/exporters/langfuse): Langfuse integration
|
|
189
|
+
- [Braintrust](https://mastra.ai/reference/observability/tracing/exporters/braintrust): Braintrust integration
|
|
190
|
+
|
|
191
|
+
### Reference
|
|
192
|
+
|
|
193
|
+
- [Configuration](https://mastra.ai/reference/observability/tracing/configuration): Configuration options
|
|
194
|
+
- [Interfaces](https://mastra.ai/reference/observability/tracing/interfaces): Type definitions
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OtelExporter
|
|
2
2
|
|
|
3
|
-
Sends
|
|
3
|
+
Sends traces and logs to any OpenTelemetry-compatible observability platform. Traces use the standardized GenAI semantic conventions; logs carry their original severity and message body and are correlated to traces via both the OTEL log record's native trace context and `mastra.traceId` / `mastra.spanId` attributes.
|
|
4
4
|
|
|
5
5
|
## Constructor
|
|
6
6
|
|
|
@@ -13,6 +13,10 @@ new OtelExporter(config: OtelExporterConfig)
|
|
|
13
13
|
```typescript
|
|
14
14
|
interface OtelExporterConfig {
|
|
15
15
|
provider?: ProviderConfig
|
|
16
|
+
signals?: {
|
|
17
|
+
traces?: boolean
|
|
18
|
+
logs?: boolean
|
|
19
|
+
}
|
|
16
20
|
timeout?: number
|
|
17
21
|
batchSize?: number
|
|
18
22
|
logLevel?: 'debug' | 'info' | 'warn' | 'error'
|
|
@@ -157,14 +161,14 @@ const exporter = new OtelExporter({
|
|
|
157
161
|
|
|
158
162
|
## Protocol requirements
|
|
159
163
|
|
|
160
|
-
Different providers require different OTEL exporter packages:
|
|
164
|
+
Different providers require different OTEL exporter packages. Trace and log export are independent: install only the trace package if you only need traces, or install both the trace and log packages for the chosen protocol if you also want log export. Zipkin does not support OTLP logs.
|
|
161
165
|
|
|
162
|
-
| Protocol |
|
|
163
|
-
| ------------- |
|
|
164
|
-
| gRPC | `@opentelemetry/exporter-trace-otlp-grpc`
|
|
165
|
-
| HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto`
|
|
166
|
-
| HTTP/JSON | `@opentelemetry/exporter-trace-otlp-http`
|
|
167
|
-
| Zipkin | `@opentelemetry/exporter-zipkin`
|
|
166
|
+
| Protocol | Trace package | Log package |
|
|
167
|
+
| ------------- | ------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
168
|
+
| gRPC | `@opentelemetry/exporter-trace-otlp-grpc` (+ `@grpc/grpc-js`) | `@opentelemetry/exporter-logs-otlp-grpc` (+ `@grpc/grpc-js`) |
|
|
169
|
+
| HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto` | `@opentelemetry/exporter-logs-otlp-proto` |
|
|
170
|
+
| HTTP/JSON | `@opentelemetry/exporter-trace-otlp-http` | `@opentelemetry/exporter-logs-otlp-http` |
|
|
171
|
+
| Zipkin | `@opentelemetry/exporter-zipkin` | not supported |
|
|
168
172
|
|
|
169
173
|
## Tags support
|
|
170
174
|
|
|
@@ -102,6 +102,6 @@ class CustomObservabilityInstance extends BaseObservabilityInstance {
|
|
|
102
102
|
|
|
103
103
|
### Exporters
|
|
104
104
|
|
|
105
|
-
- [
|
|
106
|
-
- [
|
|
105
|
+
- [MastraStorageExporter](https://mastra.ai/reference/observability/tracing/exporters/mastra-storage-exporter): Storage persistence
|
|
106
|
+
- [MastraPlatformExporter](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter): Mastra platform integration
|
|
107
107
|
- [ConsoleExporter](https://mastra.ai/reference/observability/tracing/exporters/console-exporter): Debug output
|
|
@@ -141,10 +141,18 @@ interface ObservabilityExporter {
|
|
|
141
141
|
/** Handle feedback events */
|
|
142
142
|
onFeedbackEvent?(event: FeedbackEvent): void | Promise<void>
|
|
143
143
|
|
|
144
|
+
/** Handle exporter pipeline droppedEvent */
|
|
145
|
+
onDroppedEvent?(event: ObservabilityDropEvent): void | Promise<void>
|
|
146
|
+
|
|
144
147
|
/** Export tracing events */
|
|
145
148
|
exportTracingEvent(event: TracingEvent): Promise<void>
|
|
146
149
|
|
|
147
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* @deprecated Implement `onScoreEvent` instead. Eval scores now flow through the
|
|
152
|
+
* unified observability bus as `ScoreEvent`s. This method is preserved on the
|
|
153
|
+
* interface for backwards compatibility with existing exporters; new exporters
|
|
154
|
+
* should not implement it.
|
|
155
|
+
*/
|
|
148
156
|
addScoreToTrace?({
|
|
149
157
|
traceId,
|
|
150
158
|
spanId,
|
|
@@ -169,7 +177,34 @@ interface ObservabilityExporter {
|
|
|
169
177
|
}
|
|
170
178
|
```
|
|
171
179
|
|
|
172
|
-
Event callback payloads use observability event bus envelopes: `TracingEvent` carries span lifecycle events with `exportedSpan`, `LogEvent` wraps `ExportedLog` in `log`, `MetricEvent` wraps `ExportedMetric` in `metric`, `ScoreEvent` wraps `ExportedScore` in `score`, and `FeedbackEvent` wraps `ExportedFeedback` in `feedback`. For
|
|
180
|
+
Event callback payloads use observability event bus envelopes: `TracingEvent` carries span lifecycle events with `exportedSpan`, `LogEvent` wraps `ExportedLog` in `log`, `MetricEvent` wraps `ExportedMetric` in `metric`, `ScoreEvent` wraps `ExportedScore` in `score`, and `FeedbackEvent` wraps `ExportedFeedback` in `feedback`. For Mastra platform exporter behavior for these callbacks, see [MastraPlatformExporter](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter).
|
|
181
|
+
|
|
182
|
+
### `ObservabilityDropEvent`
|
|
183
|
+
|
|
184
|
+
Structured event emitted when the exporter pipeline drops observability events.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
type ObservabilityDropSignal = 'tracing' | 'log' | 'metric' | 'score' | 'feedback'
|
|
188
|
+
|
|
189
|
+
type ObservabilityDropReason = 'unsupported-storage' | 'retry-exhausted'
|
|
190
|
+
|
|
191
|
+
interface ObservabilityDropEvent {
|
|
192
|
+
type: 'drop'
|
|
193
|
+
signal: ObservabilityDropSignal
|
|
194
|
+
reason: ObservabilityDropReason
|
|
195
|
+
count: number
|
|
196
|
+
timestamp: Date
|
|
197
|
+
exporterName: string
|
|
198
|
+
storageName?: string
|
|
199
|
+
error?: {
|
|
200
|
+
id?: string
|
|
201
|
+
domain?: string
|
|
202
|
+
message: string
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Use `onDroppedEvent` on a custom exporter or bridge to forward these events to external metrics or alerting systems.
|
|
173
208
|
|
|
174
209
|
### `SpanOutputProcessor`
|
|
175
210
|
|
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
A SpanOutputProcessor that redacts sensitive information from span fields.
|
|
4
4
|
|
|
5
|
+
## Auto-applied by default
|
|
6
|
+
|
|
7
|
+
`Observability` automatically appends a `SensitiveDataFilter` to every configured instance's `spanOutputProcessors` so secrets are redacted before they reach exporters such as the Mastra cloud exporter. The filter runs last (after any user-provided processors) so that sensitive data introduced or surfaced by upstream processors is still redacted. You do not need to add it manually unless you want to customize its options.
|
|
8
|
+
|
|
9
|
+
To opt out or customize the auto-applied filter, use the `sensitiveDataFilter` option on the [`Observability` registry config](https://mastra.ai/reference/observability/tracing/configuration):
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Observability } from '@mastra/observability'
|
|
13
|
+
|
|
14
|
+
new Observability({
|
|
15
|
+
configs: {
|
|
16
|
+
/* ... */
|
|
17
|
+
},
|
|
18
|
+
// disable the auto-applied filter
|
|
19
|
+
sensitiveDataFilter: false,
|
|
20
|
+
// or customize it
|
|
21
|
+
// sensitiveDataFilter: { sensitiveFields: ['mySecret'], redactionStyle: 'partial' },
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If a config already includes a `SensitiveDataFilter` in `spanOutputProcessors`, the auto-applied filter is skipped to avoid double redaction. Pre-instantiated `ObservabilityInstance` values are not modified — add a `SensitiveDataFilter` to their processors yourself if needed.
|
|
26
|
+
|
|
5
27
|
## Constructor
|
|
6
28
|
|
|
7
29
|
```typescript
|
|
@@ -11,7 +11,7 @@ The following example demonstrates how to combine `excludeSpanTypes` and `spanFi
|
|
|
11
11
|
```ts
|
|
12
12
|
import { Mastra } from '@mastra/core'
|
|
13
13
|
import { SpanType } from '@mastra/core/observability'
|
|
14
|
-
import { Observability,
|
|
14
|
+
import { Observability, MastraStorageExporter } from '@mastra/observability'
|
|
15
15
|
import { LangfuseExporter } from '@mastra/langfuse'
|
|
16
16
|
|
|
17
17
|
export const mastra = new Mastra({
|
|
@@ -19,7 +19,7 @@ export const mastra = new Mastra({
|
|
|
19
19
|
configs: {
|
|
20
20
|
default: {
|
|
21
21
|
serviceName: 'my-app',
|
|
22
|
-
exporters: [new
|
|
22
|
+
exporters: [new MastraStorageExporter(), new LangfuseExporter()],
|
|
23
23
|
excludeSpanTypes: [SpanType.MODEL_CHUNK, SpanType.MODEL_STEP],
|
|
24
24
|
spanFilter: span => {
|
|
25
25
|
if (span.type === SpanType.TOOL_CALL && span.attributes?.success) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The `PrefillErrorHandler` is an **error processor** that handles assistant-response prefill errors. This error occurs when a conversation ends with an assistant message and the model rejects the request because it interprets it as prefilling the assistant response.
|
|
4
4
|
|
|
5
|
-
When the error is detected, the processor
|
|
5
|
+
When the error is detected, the processor sends a hidden `system-reminder` signal with `continue` as its contents and signals a retry. The reminder is persisted as signal metadata, which keeps it available for retry reconstruction and raw history while standard UI-facing message conversions hide it.
|
|
6
6
|
|
|
7
7
|
Add this processor to `errorProcessors` when you want Mastra to recover from assistant prefill rejections (for example Anthropic's "assistant message prefill" and Qwen/llama.cpp's "assistant response prefill is incompatible with `enable_thinking`" errors).
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ Add this processor to `errorProcessors` when you want Mastra to recover from ass
|
|
|
10
10
|
|
|
11
11
|
1. The LLM API call fails with a known assistant-prefill rejection message
|
|
12
12
|
2. `PrefillErrorHandler` checks that this is the first retry attempt
|
|
13
|
-
3. It
|
|
13
|
+
3. It sends a hidden `system-reminder` signal with `continue` as its contents
|
|
14
14
|
4. It returns `{ retry: true }` to signal the LLM call should be retried with the modified messages
|
|
15
15
|
|
|
16
16
|
The processor now reacts to the API rejection itself instead of re-checking whether the conversation currently ends with an assistant message. This makes it resilient to cases where the provider rejects the request for prefill semantics even if the trailing message shape has already been transformed upstream.
|
|
@@ -62,7 +62,7 @@ The `PrefillErrorHandler` takes no constructor parameters.
|
|
|
62
62
|
|
|
63
63
|
**name** (`'Prefill Error Handler'`): Processor display name.
|
|
64
64
|
|
|
65
|
-
**processAPIError** (`(args: ProcessAPIErrorArgs) => ProcessAPIErrorResult | void`): Handles known assistant-prefill errors by
|
|
65
|
+
**processAPIError** (`(args: ProcessAPIErrorArgs) => ProcessAPIErrorResult | void`): Handles known assistant-prefill errors by sending a hidden system reminder signal and signaling retry. Only triggers on the first retry attempt.
|
|
66
66
|
|
|
67
67
|
## Related
|
|
68
68
|
|