@mastra/mcp-docs-server 1.1.35-alpha.2 → 1.1.35-alpha.26
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 +35 -3
- 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/editor/tools.md +1 -1
- package/.docs/docs/index.md +2 -2
- package/.docs/docs/mastra-platform/configuration.md +1 -1
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/memory/observational-memory.md +63 -14
- package/.docs/docs/memory/overview.md +2 -1
- 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 +6 -6
- 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} +28 -26
- 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/observability.md +4 -4
- package/.docs/docs/studio/overview.md +4 -0
- package/.docs/docs/voice/overview.md +84 -0
- package/.docs/docs/workflows/suspend-and-resume.md +28 -1
- package/.docs/guides/deployment/inngest.md +29 -8
- package/.docs/guides/guide/web-search.md +7 -7
- package/.docs/guides/migrations/mastra-cloud.md +6 -6
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +19 -17
- package/.docs/models/gateways/azure-openai.md +94 -23
- package/.docs/models/gateways/netlify.md +3 -1
- package/.docs/models/gateways/openrouter.md +5 -1
- package/.docs/models/gateways/vercel.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/chutes.md +23 -54
- package/.docs/models/providers/databricks.md +96 -0
- package/.docs/models/providers/deepinfra.md +2 -1
- package/.docs/models/providers/deepseek.md +3 -1
- package/.docs/models/providers/digitalocean.md +10 -2
- package/.docs/models/providers/firepass.md +71 -0
- package/.docs/models/providers/google.md +3 -2
- package/.docs/models/providers/kilo.md +5 -3
- package/.docs/models/providers/kiro.md +110 -0
- 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-go.md +2 -4
- package/.docs/models/providers/opencode.md +44 -43
- package/.docs/models/providers/poe.md +4 -1
- package/.docs/models/providers/qiniu-ai.md +2 -2
- package/.docs/models/providers/sarvam.md +72 -0
- package/.docs/models/providers/wafer.ai.md +2 -1
- 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/xiaomi.md +2 -2
- package/.docs/models/providers/zenmux.md +1 -1
- package/.docs/models/providers.md +3 -0
- 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/mastra.md +464 -0
- 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 +23 -8
- package/.docs/reference/index.md +6 -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 +3 -1
- 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/processor-interface.md +74 -12
- package/.docs/reference/processors/provider-history-compat.md +132 -0
- 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/streaming/agents/stream.md +18 -2
- package/.docs/reference/tools/brightdata.md +167 -0
- package/.docs/reference/tools/create-tool.md +46 -0
- package/.docs/reference/tools/mcp-client.md +47 -0
- package/.docs/reference/voice/inworld.md +133 -0
- package/.docs/reference/workflows/workflow-state-reader.md +113 -0
- package/CHANGELOG.md +92 -0
- package/package.json +4 -4
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mastra Storage exporter
|
|
2
2
|
|
|
3
|
-
The `
|
|
3
|
+
The `MastraStorageExporter` persists traces to your configured storage backend, making them accessible through Studio. It requires no external services.
|
|
4
|
+
|
|
5
|
+
> **Note:** `MastraStorageExporter` was previously called `DefaultExporter`. The original `DefaultExporter` class is still exported from `@mastra/observability` for backward compatibility, but it is deprecated. New code should use `MastraStorageExporter`.
|
|
4
6
|
|
|
5
7
|
> **Production Observability:** Observability data can quickly overwhelm general-purpose databases in production. For high-traffic applications, route the observability storage domain to [ClickHouse](https://mastra.ai/reference/storage/clickhouse) through [composite storage](https://mastra.ai/reference/storage/composite). See [Production Recommendations](#production-recommendations) for details.
|
|
6
8
|
|
|
@@ -15,7 +17,7 @@ The `DefaultExporter` persists traces to your configured storage backend, making
|
|
|
15
17
|
|
|
16
18
|
```typescript
|
|
17
19
|
import { Mastra } from '@mastra/core'
|
|
18
|
-
import { Observability,
|
|
20
|
+
import { Observability, MastraStorageExporter } from '@mastra/observability'
|
|
19
21
|
import { LibSQLStore } from '@mastra/libsql'
|
|
20
22
|
|
|
21
23
|
export const mastra = new Mastra({
|
|
@@ -27,7 +29,7 @@ export const mastra = new Mastra({
|
|
|
27
29
|
configs: {
|
|
28
30
|
local: {
|
|
29
31
|
serviceName: 'my-service',
|
|
30
|
-
exporters: [new
|
|
32
|
+
exporters: [new MastraStorageExporter()],
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
}),
|
|
@@ -36,14 +38,14 @@ export const mastra = new Mastra({
|
|
|
36
38
|
|
|
37
39
|
### Recommended Configuration
|
|
38
40
|
|
|
39
|
-
Include
|
|
41
|
+
Include MastraStorageExporter in your observability configuration:
|
|
40
42
|
|
|
41
43
|
```typescript
|
|
42
44
|
import { Mastra } from '@mastra/core'
|
|
43
45
|
import {
|
|
44
46
|
Observability,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
MastraStorageExporter,
|
|
48
|
+
MastraPlatformExporter,
|
|
47
49
|
SensitiveDataFilter,
|
|
48
50
|
} from '@mastra/observability'
|
|
49
51
|
import { LibSQLStore } from '@mastra/libsql'
|
|
@@ -58,8 +60,8 @@ export const mastra = new Mastra({
|
|
|
58
60
|
default: {
|
|
59
61
|
serviceName: 'mastra',
|
|
60
62
|
exporters: [
|
|
61
|
-
new
|
|
62
|
-
new
|
|
63
|
+
new MastraStorageExporter(), // Persists observability events to Mastra Storage
|
|
64
|
+
new MastraPlatformExporter(), // Sends observability events to Mastra Platform (requires MASTRA_CLOUD_ACCESS_TOKEN)
|
|
63
65
|
],
|
|
64
66
|
spanOutputProcessors: [new SensitiveDataFilter()],
|
|
65
67
|
},
|
|
@@ -79,7 +81,7 @@ Access your traces through Studio:
|
|
|
79
81
|
|
|
80
82
|
## Tracing strategies
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
MastraStorageExporter automatically selects the optimal tracing strategy based on your storage provider. You can also override this selection if needed.
|
|
83
85
|
|
|
84
86
|
### Available Strategies
|
|
85
87
|
|
|
@@ -92,7 +94,7 @@ DefaultExporter automatically selects the optimal tracing strategy based on your
|
|
|
92
94
|
### Strategy Configuration
|
|
93
95
|
|
|
94
96
|
```typescript
|
|
95
|
-
new
|
|
97
|
+
new MastraStorageExporter({
|
|
96
98
|
strategy: 'auto', // Default - let storage provider decide
|
|
97
99
|
// or explicitly set:
|
|
98
100
|
// strategy: 'realtime' | 'batch-with-updates' | 'insert-only'
|
|
@@ -108,7 +110,7 @@ new DefaultExporter({
|
|
|
108
110
|
|
|
109
111
|
Different storage providers support different tracing strategies. Some providers support observability for production workloads, while others are intended primarily for local development.
|
|
110
112
|
|
|
111
|
-
If you set the strategy to `'auto'`, the `
|
|
113
|
+
If you set the strategy to `'auto'`, the `MastraStorageExporter` automatically selects the optimal strategy for the storage provider. If you set an explicit strategy that the storage provider doesn't support, the exporter logs a warning and falls back to the provider's preferred strategy.
|
|
112
114
|
|
|
113
115
|
### Providers with Observability Support
|
|
114
116
|
|
|
@@ -167,33 +169,68 @@ For both batch strategies (`batch-with-updates` and `insert-only`), traces are f
|
|
|
167
169
|
|
|
168
170
|
### Error handling
|
|
169
171
|
|
|
170
|
-
The
|
|
172
|
+
The MastraStorageExporter includes robust error handling for production use:
|
|
171
173
|
|
|
172
174
|
- **Retry Logic**: Exponential backoff (500ms, 1s, 2s, 4s)
|
|
173
175
|
- **Transient Failures**: Automatic retry with backoff
|
|
174
176
|
- **Persistent Failures**: Drop batch after 4 failed attempts
|
|
175
177
|
- **Buffer Overflow**: Prevent memory issues during storage outages
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
## Dropped observability events
|
|
180
|
+
|
|
181
|
+
`DefaultExporter` emits structured drop events when it cannot persist observability data. Register an exporter or bridge with `onDroppedEvent` to forward these drops to alerting or monitoring.
|
|
182
|
+
|
|
183
|
+
There are two drop reasons:
|
|
184
|
+
|
|
185
|
+
- `unsupported-storage`: The storage provider does not implement the signal type.
|
|
186
|
+
- `retry-exhausted`: The exporter retried a batch up to `maxRetries` times and then dropped it.
|
|
187
|
+
|
|
188
|
+
The following example demonstrates forwarding drop details to a monitoring endpoint:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import { BaseExporter } from '@mastra/observability'
|
|
192
|
+
import type { ObservabilityDropEvent, TracingEvent } from '@mastra/core/observability'
|
|
193
|
+
|
|
194
|
+
class DropAlertExporter extends BaseExporter {
|
|
195
|
+
name = 'drop-alerts'
|
|
196
|
+
|
|
197
|
+
async onDroppedEvent(event: ObservabilityDropEvent) {
|
|
198
|
+
await fetch('https://monitoring.example.com/observability-drops', {
|
|
199
|
+
method: 'POST',
|
|
200
|
+
headers: { 'content-type': 'application/json' },
|
|
201
|
+
body: JSON.stringify({
|
|
202
|
+
count: event.count,
|
|
203
|
+
signal: event.signal,
|
|
204
|
+
reason: event.reason,
|
|
205
|
+
exporterName: event.exporterName,
|
|
206
|
+
}),
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
protected async _exportTracingEvent(_event: TracingEvent) {}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Configuration examples
|
|
178
215
|
|
|
179
216
|
```typescript
|
|
180
217
|
// Zero config - recommended for most users
|
|
181
|
-
new
|
|
218
|
+
new MastraStorageExporter()
|
|
182
219
|
|
|
183
220
|
// Development override
|
|
184
|
-
new
|
|
221
|
+
new MastraStorageExporter({
|
|
185
222
|
strategy: 'realtime', // Immediate visibility for debugging
|
|
186
223
|
})
|
|
187
224
|
|
|
188
225
|
// High-throughput production
|
|
189
|
-
new
|
|
226
|
+
new MastraStorageExporter({
|
|
190
227
|
maxBatchSize: 2000, // Larger batches
|
|
191
228
|
maxBatchWaitMs: 10000, // Wait longer to fill batches
|
|
192
229
|
maxBufferSize: 50000, // Handle longer outages
|
|
193
230
|
})
|
|
194
231
|
|
|
195
232
|
// Low-latency production
|
|
196
|
-
new
|
|
233
|
+
new MastraStorageExporter({
|
|
197
234
|
maxBatchSize: 100, // Smaller batches
|
|
198
235
|
maxBatchWaitMs: 1000, // Flush quickly
|
|
199
236
|
})
|
|
@@ -202,6 +239,6 @@ new DefaultExporter({
|
|
|
202
239
|
## Related
|
|
203
240
|
|
|
204
241
|
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
205
|
-
- [
|
|
242
|
+
- [MastraPlatformExporter](https://mastra.ai/docs/observability/tracing/exporters/mastra-platform)
|
|
206
243
|
- [Composite Storage](https://mastra.ai/reference/storage/composite): Combine multiple storage providers
|
|
207
244
|
- [Storage Configuration](https://mastra.ai/docs/memory/storage)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenTelemetry exporter
|
|
2
2
|
|
|
3
|
-
The OpenTelemetry (OTEL) exporter sends your traces to any OTEL-compatible observability platform using standardized [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/). This ensures broad compatibility with platforms like Datadog, New Relic, SigNoz, MLflow, Dash0, Traceloop, Laminar, and more.
|
|
3
|
+
The OpenTelemetry (OTEL) exporter sends your traces and logs to any OTEL-compatible observability platform using standardized [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/). This ensures broad compatibility with platforms like Datadog, New Relic, SigNoz, MLflow, Dash0, Traceloop, Laminar, and more.
|
|
4
4
|
|
|
5
5
|
> **Looking for bidirectional OTEL integration?:** If you have existing OpenTelemetry instrumentation and want Mastra traces to inherit context from active OTEL spans, see the [OpenTelemetry Bridge](https://mastra.ai/docs/observability/tracing/bridges/otel) instead.
|
|
6
6
|
|
|
@@ -389,6 +389,77 @@ new OtelExporter({
|
|
|
389
389
|
})
|
|
390
390
|
```
|
|
391
391
|
|
|
392
|
+
## Signals
|
|
393
|
+
|
|
394
|
+
The exporter sends two OpenTelemetry signals:
|
|
395
|
+
|
|
396
|
+
- Traces: Mastra spans, exported via `BatchSpanProcessor`.
|
|
397
|
+
- Logs: Mastra log events, exported via `BatchLogRecordProcessor`. Logs that carry `traceId` and `spanId` are correlated with traces using both the OTEL log record's native trace context and `mastra.traceId` / `mastra.spanId` attributes, so backends like Datadog, Grafana, and Honeycomb can join logs to traces automatically.
|
|
398
|
+
|
|
399
|
+
Both signals are enabled by default and share the same provider configuration. The log endpoint is derived from the trace endpoint by replacing the `/v1/traces` suffix with `/v1/logs`.
|
|
400
|
+
|
|
401
|
+
To disable a signal, set the `signals` option:
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
new OtelExporter({
|
|
405
|
+
provider: {
|
|
406
|
+
/* ... */
|
|
407
|
+
},
|
|
408
|
+
signals: {
|
|
409
|
+
traces: true, // default
|
|
410
|
+
logs: false, // disable log export
|
|
411
|
+
},
|
|
412
|
+
})
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Log export requires installing the matching OTLP log exporter package for your protocol:
|
|
416
|
+
|
|
417
|
+
**npm**:
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
# HTTP/JSON
|
|
421
|
+
npm install @opentelemetry/exporter-logs-otlp-http
|
|
422
|
+
# HTTP/Protobuf
|
|
423
|
+
npm install @opentelemetry/exporter-logs-otlp-proto
|
|
424
|
+
# gRPC
|
|
425
|
+
npm install @opentelemetry/exporter-logs-otlp-grpc @grpc/grpc-js
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
**pnpm**:
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
# HTTP/JSON
|
|
432
|
+
pnpm add @opentelemetry/exporter-logs-otlp-http
|
|
433
|
+
# HTTP/Protobuf
|
|
434
|
+
pnpm add @opentelemetry/exporter-logs-otlp-proto
|
|
435
|
+
# gRPC
|
|
436
|
+
pnpm add @opentelemetry/exporter-logs-otlp-grpc @grpc/grpc-js
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
**Yarn**:
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
# HTTP/JSON
|
|
443
|
+
yarn add @opentelemetry/exporter-logs-otlp-http
|
|
444
|
+
# HTTP/Protobuf
|
|
445
|
+
yarn add @opentelemetry/exporter-logs-otlp-proto
|
|
446
|
+
# gRPC
|
|
447
|
+
yarn add @opentelemetry/exporter-logs-otlp-grpc @grpc/grpc-js
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**Bun**:
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
# HTTP/JSON
|
|
454
|
+
bun add @opentelemetry/exporter-logs-otlp-http
|
|
455
|
+
# HTTP/Protobuf
|
|
456
|
+
bun add @opentelemetry/exporter-logs-otlp-proto
|
|
457
|
+
# gRPC
|
|
458
|
+
bun add @opentelemetry/exporter-logs-otlp-grpc @grpc/grpc-js
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
If the matching log exporter package is not installed, log export is silently disabled and traces continue to work.
|
|
462
|
+
|
|
392
463
|
## Configuration options
|
|
393
464
|
|
|
394
465
|
### Complete Configuration
|
|
@@ -400,9 +471,15 @@ new OtelExporter({
|
|
|
400
471
|
// Use one of: dash0, signoz, newrelic, traceloop, laminar, custom
|
|
401
472
|
},
|
|
402
473
|
|
|
474
|
+
// Per-signal toggles. Both default to true.
|
|
475
|
+
signals: {
|
|
476
|
+
traces: true,
|
|
477
|
+
logs: true,
|
|
478
|
+
},
|
|
479
|
+
|
|
403
480
|
// Export configuration
|
|
404
481
|
timeout: 30000, // Export timeout in milliseconds
|
|
405
|
-
batchSize: 100, // Number of spans per batch
|
|
482
|
+
batchSize: 100, // Number of spans/logs per batch
|
|
406
483
|
|
|
407
484
|
// Debug options
|
|
408
485
|
logLevel: 'info', // 'debug' | 'info' | 'warn' | 'error'
|
|
@@ -18,10 +18,11 @@ Traces are created by:
|
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
20
|
import { Mastra } from '@mastra/core'
|
|
21
|
+
import { LibSQLStore } from '@mastra/libsql'
|
|
21
22
|
import {
|
|
22
23
|
Observability,
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
MastraStorageExporter,
|
|
25
|
+
MastraPlatformExporter,
|
|
25
26
|
SensitiveDataFilter,
|
|
26
27
|
} from '@mastra/observability'
|
|
27
28
|
|
|
@@ -31,8 +32,8 @@ export const mastra = new Mastra({
|
|
|
31
32
|
default: {
|
|
32
33
|
serviceName: 'mastra',
|
|
33
34
|
exporters: [
|
|
34
|
-
new
|
|
35
|
-
new
|
|
35
|
+
new MastraStorageExporter(), // Persists observability events to Mastra Storage
|
|
36
|
+
new MastraPlatformExporter(), // Sends observability events to Mastra Platform (if MASTRA_CLOUD_ACCESS_TOKEN is set)
|
|
36
37
|
],
|
|
37
38
|
spanOutputProcessors: [
|
|
38
39
|
new SensitiveDataFilter(), // Redacts sensitive data like passwords, tokens, keys
|
|
@@ -55,8 +56,8 @@ This configuration includes:
|
|
|
55
56
|
|
|
56
57
|
- **Exporters**:
|
|
57
58
|
|
|
58
|
-
- `
|
|
59
|
-
- `
|
|
59
|
+
- `MastraStorageExporter` - Persists observability events to Mastra Storage
|
|
60
|
+
- `MastraPlatformExporter` - Sends observability events to Mastra Platform (requires `MASTRA_CLOUD_ACCESS_TOKEN`)
|
|
60
61
|
|
|
61
62
|
- **Span Output Processors**: `SensitiveDataFilter` - Redacts sensitive fields
|
|
62
63
|
|
|
@@ -68,8 +69,8 @@ Exporters determine where your trace data is sent and how it's stored. They inte
|
|
|
68
69
|
|
|
69
70
|
Mastra provides two built-in exporters:
|
|
70
71
|
|
|
71
|
-
- **[
|
|
72
|
-
- **[
|
|
72
|
+
- **[Mastra Storage](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage)** - Persists observability events to Mastra Storage for viewing in Studio
|
|
73
|
+
- **[Mastra Platform](https://mastra.ai/docs/observability/tracing/exporters/mastra-platform)** - Sends observability events to Mastra Platform for production monitoring and collaboration
|
|
73
74
|
|
|
74
75
|
### External Exporters
|
|
75
76
|
|
|
@@ -172,7 +173,7 @@ export const mastra = new Mastra({
|
|
|
172
173
|
type: 'ratio',
|
|
173
174
|
probability: 0.1,
|
|
174
175
|
},
|
|
175
|
-
exporters: [new
|
|
176
|
+
exporters: [new MastraStorageExporter()],
|
|
176
177
|
},
|
|
177
178
|
},
|
|
178
179
|
}),
|
|
@@ -212,7 +213,7 @@ export const mastra = new Mastra({
|
|
|
212
213
|
debug: {
|
|
213
214
|
serviceName: 'debug-service',
|
|
214
215
|
sampling: { type: 'always' },
|
|
215
|
-
exporters: [new
|
|
216
|
+
exporters: [new MastraStorageExporter()],
|
|
216
217
|
},
|
|
217
218
|
},
|
|
218
219
|
configSelector: (context, availableTracers) => {
|
|
@@ -249,7 +250,7 @@ export const mastra = new Mastra({
|
|
|
249
250
|
development: {
|
|
250
251
|
serviceName: 'my-service-dev',
|
|
251
252
|
sampling: { type: 'always' },
|
|
252
|
-
exporters: [new
|
|
253
|
+
exporters: [new MastraStorageExporter()],
|
|
253
254
|
},
|
|
254
255
|
staging: {
|
|
255
256
|
serviceName: 'my-service-staging',
|
|
@@ -259,7 +260,7 @@ export const mastra = new Mastra({
|
|
|
259
260
|
production: {
|
|
260
261
|
serviceName: 'my-service-prod',
|
|
261
262
|
sampling: { type: 'ratio', probability: 0.01 },
|
|
262
|
-
exporters: [
|
|
263
|
+
exporters: [mastraObserveExporter, langfuseExporter],
|
|
263
264
|
},
|
|
264
265
|
},
|
|
265
266
|
configSelector: (context, availableTracers) => {
|
|
@@ -274,13 +275,13 @@ export const mastra = new Mastra({
|
|
|
274
275
|
|
|
275
276
|
#### Maintaining Studio access
|
|
276
277
|
|
|
277
|
-
When adding external exporters, include `
|
|
278
|
+
When adding external exporters, include `MastraStorageExporter` and `MastraPlatformExporter` to maintain access to Studio:
|
|
278
279
|
|
|
279
280
|
```ts
|
|
280
281
|
import {
|
|
281
282
|
Observability,
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
MastraStorageExporter,
|
|
284
|
+
MastraPlatformExporter,
|
|
284
285
|
SensitiveDataFilter,
|
|
285
286
|
} from '@mastra/observability'
|
|
286
287
|
import { ArizeExporter } from '@mastra/arize'
|
|
@@ -292,11 +293,11 @@ export const mastra = new Mastra({
|
|
|
292
293
|
serviceName: 'my-service',
|
|
293
294
|
exporters: [
|
|
294
295
|
new ArizeExporter({
|
|
295
|
-
endpoint: process.env.
|
|
296
|
+
endpoint: process.env.PHOENIX_COLLECTOR_ENDPOINT,
|
|
296
297
|
apiKey: process.env.PHOENIX_API_KEY,
|
|
297
298
|
}),
|
|
298
|
-
new
|
|
299
|
-
new
|
|
299
|
+
new MastraStorageExporter(), // Keep Studio access
|
|
300
|
+
new MastraPlatformExporter(), // Keep Cloud access
|
|
300
301
|
],
|
|
301
302
|
spanOutputProcessors: [new SensitiveDataFilter()],
|
|
302
303
|
},
|
|
@@ -308,8 +309,8 @@ export const mastra = new Mastra({
|
|
|
308
309
|
This configuration sends traces to all three destinations simultaneously:
|
|
309
310
|
|
|
310
311
|
- **Arize Phoenix/AX** for external observability
|
|
311
|
-
- **
|
|
312
|
-
- **
|
|
312
|
+
- **MastraStorageExporter** for Studio
|
|
313
|
+
- **MastraPlatformExporter** for hosted Studio dashboard
|
|
313
314
|
|
|
314
315
|
> **Info:** Remember: A single trace can be sent to multiple exporters. You don't need separate configs for each exporter unless you want different sampling rates or processors.
|
|
315
316
|
|
|
@@ -352,7 +353,7 @@ export const mastra = new Mastra({
|
|
|
352
353
|
configs: {
|
|
353
354
|
default: {
|
|
354
355
|
serviceName: 'my-service',
|
|
355
|
-
exporters: [new
|
|
356
|
+
exporters: [new MastraStorageExporter()],
|
|
356
357
|
},
|
|
357
358
|
},
|
|
358
359
|
}),
|
|
@@ -378,7 +379,7 @@ export const mastra = new Mastra({
|
|
|
378
379
|
default: {
|
|
379
380
|
serviceName: 'my-service',
|
|
380
381
|
requestContextKeys: ['userId', 'environment', 'tenantId'],
|
|
381
|
-
exporters: [new
|
|
382
|
+
exporters: [new MastraStorageExporter()],
|
|
382
383
|
},
|
|
383
384
|
},
|
|
384
385
|
}),
|
|
@@ -429,7 +430,7 @@ export const mastra = new Mastra({
|
|
|
429
430
|
configs: {
|
|
430
431
|
default: {
|
|
431
432
|
requestContextKeys: ['user.id', 'session.data.experimentId'],
|
|
432
|
-
exporters: [new
|
|
433
|
+
exporters: [new MastraStorageExporter()],
|
|
433
434
|
},
|
|
434
435
|
},
|
|
435
436
|
}),
|
|
@@ -667,7 +668,7 @@ export const mastra = new Mastra({
|
|
|
667
668
|
configs: {
|
|
668
669
|
development: {
|
|
669
670
|
spanOutputProcessors: [new LowercaseInputProcessor(), new SensitiveDataFilter()],
|
|
670
|
-
exporters: [new
|
|
671
|
+
exporters: [new MastraStorageExporter()],
|
|
671
672
|
},
|
|
672
673
|
},
|
|
673
674
|
}),
|
|
@@ -694,7 +695,7 @@ The following example demonstrates how to combine both options in a single confi
|
|
|
694
695
|
```ts
|
|
695
696
|
import { Mastra } from '@mastra/core'
|
|
696
697
|
import { SpanType } from '@mastra/core/observability'
|
|
697
|
-
import { Observability,
|
|
698
|
+
import { Observability, MastraStorageExporter } from '@mastra/observability'
|
|
698
699
|
import { LangfuseExporter } from '@mastra/langfuse'
|
|
699
700
|
|
|
700
701
|
export const mastra = new Mastra({
|
|
@@ -702,7 +703,7 @@ export const mastra = new Mastra({
|
|
|
702
703
|
configs: {
|
|
703
704
|
default: {
|
|
704
705
|
serviceName: 'my-app',
|
|
705
|
-
exporters: [new
|
|
706
|
+
exporters: [new MastraStorageExporter(), new LangfuseExporter()],
|
|
706
707
|
excludeSpanTypes: [SpanType.MODEL_CHUNK, SpanType.MODEL_STEP],
|
|
707
708
|
spanFilter: span => {
|
|
708
709
|
if (span.type === SpanType.TOOL_CALL && span.attributes?.success) {
|
|
@@ -880,7 +881,7 @@ export const mastra = new Mastra({
|
|
|
880
881
|
maxArrayLength: 100, // Maximum number of items in arrays (default: 50)
|
|
881
882
|
maxObjectKeys: 75, // Maximum number of keys in objects (default: 50)
|
|
882
883
|
},
|
|
883
|
-
exporters: [new
|
|
884
|
+
exporters: [new MastraStorageExporter()],
|
|
884
885
|
},
|
|
885
886
|
},
|
|
886
887
|
}),
|
|
@@ -1161,8 +1162,8 @@ Mastra automatically creates spans for:
|
|
|
1161
1162
|
|
|
1162
1163
|
### Exporters
|
|
1163
1164
|
|
|
1164
|
-
- [
|
|
1165
|
-
- [
|
|
1165
|
+
- [MastraStorageExporter](https://mastra.ai/reference/observability/tracing/exporters/mastra-storage-exporter): Storage persistence
|
|
1166
|
+
- [MastraPlatformExporter](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter): Mastra platform integration
|
|
1166
1167
|
- [ConsoleExporter](https://mastra.ai/reference/observability/tracing/exporters/console-exporter): Debug output
|
|
1167
1168
|
- [Arize](https://mastra.ai/reference/observability/tracing/exporters/arize): Arize Phoenix and Arize AX integration
|
|
1168
1169
|
- [Braintrust](https://mastra.ai/reference/observability/tracing/exporters/braintrust): Braintrust integration
|
|
@@ -9,8 +9,8 @@ The Sensitive Data Filter is included in the recommended observability configura
|
|
|
9
9
|
```ts
|
|
10
10
|
import {
|
|
11
11
|
Observability,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
MastraStorageExporter,
|
|
13
|
+
MastraPlatformExporter,
|
|
14
14
|
SensitiveDataFilter,
|
|
15
15
|
} from '@mastra/observability'
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ export const mastra = new Mastra({
|
|
|
19
19
|
configs: {
|
|
20
20
|
default: {
|
|
21
21
|
serviceName: 'mastra',
|
|
22
|
-
exporters: [new
|
|
22
|
+
exporters: [new MastraStorageExporter(), new MastraPlatformExporter()],
|
|
23
23
|
spanOutputProcessors: [
|
|
24
24
|
new SensitiveDataFilter(), // Redacts sensitive fields before export
|
|
25
25
|
],
|
|
@@ -70,14 +70,14 @@ When a sensitive field is detected, its value is replaced with `[REDACTED]` by d
|
|
|
70
70
|
You can customize which fields are redacted and how redaction displays:
|
|
71
71
|
|
|
72
72
|
```ts
|
|
73
|
-
import { SensitiveDataFilter,
|
|
73
|
+
import { SensitiveDataFilter, MastraStorageExporter, Observability } from '@mastra/observability'
|
|
74
74
|
|
|
75
75
|
export const mastra = new Mastra({
|
|
76
76
|
observability: new Observability({
|
|
77
77
|
configs: {
|
|
78
78
|
production: {
|
|
79
79
|
serviceName: 'my-service',
|
|
80
|
-
exporters: [new
|
|
80
|
+
exporters: [new MastraStorageExporter()],
|
|
81
81
|
spanOutputProcessors: [
|
|
82
82
|
new SensitiveDataFilter({
|
|
83
83
|
// Add custom sensitive fields
|
|
@@ -226,7 +226,7 @@ export const mastra = new Mastra({
|
|
|
226
226
|
debug: {
|
|
227
227
|
serviceName: 'debug-service',
|
|
228
228
|
spanOutputProcessors: [], // No processors, including no SensitiveDataFilter
|
|
229
|
-
exporters: [new
|
|
229
|
+
exporters: [new MastraStorageExporter()],
|
|
230
230
|
},
|
|
231
231
|
},
|
|
232
232
|
}),
|
|
@@ -4,17 +4,15 @@ Mastra runs as an HTTP server that exposes your agents, workflows, and other fun
|
|
|
4
4
|
|
|
5
5
|
> **Info:** This page covers the [`server`](https://mastra.ai/reference/configuration) configuration options passed to the `Mastra` constructor. For running Mastra with your own HTTP server (Hono, Express, etc.), visit [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
6
6
|
|
|
7
|
-
## Server
|
|
8
|
-
|
|
9
|
-
Mastra uses [Hono](https://hono.dev) as its underlying HTTP server framework. When you build a Mastra application using `mastra build`, it generates a Hono-based HTTP server in the `.mastra` directory.
|
|
10
|
-
|
|
11
|
-
The server provides:
|
|
7
|
+
## Server features
|
|
12
8
|
|
|
13
|
-
-
|
|
14
|
-
- Custom API routes
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
9
|
+
- **[Middleware](https://mastra.ai/docs/server/middleware)**: Intercept requests for authentication, logging, CORS, or injecting request-specific context.
|
|
10
|
+
- **[Custom API Routes](https://mastra.ai/docs/server/custom-api-routes)**: Extend the server with your own HTTP endpoints that have access to the Mastra instance.
|
|
11
|
+
- **[Request Context](https://mastra.ai/docs/server/request-context)**: Pass request-specific values to agents, tools, and workflows based on runtime conditions.
|
|
12
|
+
- **[Server Adapters](https://mastra.ai/docs/server/server-adapters)**: Run Mastra with Express, Hono, or your own HTTP server instead of the generated server.
|
|
13
|
+
- **[Custom Adapters](https://mastra.ai/docs/server/custom-adapters)**: Build adapters for frameworks not officially supported.
|
|
14
|
+
- **[Mastra Client SDK](https://mastra.ai/docs/server/mastra-client)**: Type-safe client for calling agents, workflows, and tools from browser or server environments.
|
|
15
|
+
- **[Authentication](https://mastra.ai/docs/server/auth)**: Secure endpoints with JWT, Clerk, Supabase, Firebase, Auth0, or WorkOS.
|
|
18
16
|
|
|
19
17
|
## Configuration
|
|
20
18
|
|
|
@@ -33,15 +31,21 @@ export const mastra = new Mastra({
|
|
|
33
31
|
|
|
34
32
|
> **Info:** Visit the [configuration reference](https://mastra.ai/reference/configuration) for a full list of available server options.
|
|
35
33
|
|
|
36
|
-
##
|
|
34
|
+
## Deploy your server
|
|
37
35
|
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
Mastra servers can be deployed to any Node.js-compatible environment. Deploy it to production using the [Mastra platform](https://mastra.ai/docs/mastra-platform/overview) or your own infastructure. Visit the [deployment docs](https://mastra.ai/docs/deployment/overview) to learn how.
|
|
37
|
+
|
|
38
|
+
## Server architecture
|
|
39
|
+
|
|
40
|
+
Mastra uses [Hono](https://hono.dev) as its underlying HTTP server framework. When you build a Mastra application using `mastra build`, it generates a Hono-based HTTP server in the `.mastra` directory.
|
|
41
|
+
|
|
42
|
+
The server provides:
|
|
43
|
+
|
|
44
|
+
- API endpoints for all registered agents and workflows
|
|
45
|
+
- Custom API routes and middleware
|
|
46
|
+
- Authentication across providers
|
|
47
|
+
- Request context for dynamic configuration
|
|
48
|
+
- Stream data redaction for secure responses
|
|
45
49
|
|
|
46
50
|
## REST API
|
|
47
51
|
|
|
@@ -88,4 +92,11 @@ Mastra requires `module` and `moduleResolution` settings compatible with modern
|
|
|
88
92
|
},
|
|
89
93
|
"include": ["src/**/*"]
|
|
90
94
|
}
|
|
91
|
-
```
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Next steps
|
|
98
|
+
|
|
99
|
+
- Add [middleware](https://mastra.ai/docs/server/middleware)
|
|
100
|
+
- Create [custom API routes](https://mastra.ai/docs/server/custom-api-routes)
|
|
101
|
+
- Add [authentication](https://mastra.ai/docs/server/auth)
|
|
102
|
+
- [Deploy](https://mastra.ai/docs/deployment/overview) your server to production
|
|
@@ -65,8 +65,8 @@ import { DuckDBStore } from '@mastra/duckdb'
|
|
|
65
65
|
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
66
66
|
import {
|
|
67
67
|
Observability,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
MastraStorageExporter,
|
|
69
|
+
MastraPlatformExporter,
|
|
70
70
|
SensitiveDataFilter,
|
|
71
71
|
} from '@mastra/observability'
|
|
72
72
|
|
|
@@ -86,8 +86,8 @@ export const mastra = new Mastra({
|
|
|
86
86
|
default: {
|
|
87
87
|
serviceName: 'mastra',
|
|
88
88
|
exporters: [
|
|
89
|
-
new
|
|
90
|
-
new
|
|
89
|
+
new MastraStorageExporter(), // Persists observability events to Mastra Storage
|
|
90
|
+
new MastraPlatformExporter(), // Sends observability events to Mastra Platform (if MASTRA_CLOUD_ACCESS_TOKEN is set)
|
|
91
91
|
],
|
|
92
92
|
spanOutputProcessors: [
|
|
93
93
|
new SensitiveDataFilter(), // Redacts sensitive data like passwords, tokens, keys
|
|
@@ -39,6 +39,10 @@ Once the server is running, you can:
|
|
|
39
39
|
|
|
40
40
|
While Studio is running, you can edit your [agents](https://mastra.ai/docs/agents/overview), [workflows](https://mastra.ai/docs/workflows/overview), and other parts of your Mastra application in real time.
|
|
41
41
|
|
|
42
|
+
## Deploy Studio
|
|
43
|
+
|
|
44
|
+
When you're ready to share Studio with your team, you can deploy it to production using the [Mastra platform](https://mastra.ai/docs/mastra-platform/overview) or your own infrastructure. Visit the [deployment docs](https://mastra.ai/docs/studio/deployment) to learn how.
|
|
45
|
+
|
|
42
46
|
## Primitives
|
|
43
47
|
|
|
44
48
|
### Agents
|