@mastra/mcp-docs-server 1.1.35-alpha.19 → 1.1.35-alpha.21
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/docs/agents/processors.md +8 -0
- package/.docs/docs/mastra-platform/configuration.md +1 -1
- package/.docs/docs/mastra-platform/overview.md +1 -1
- 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/exporters/braintrust.md +37 -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} +20 -18
- package/.docs/docs/observability/tracing/overview.md +29 -28
- 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/guides/deployment/inngest.md +23 -0
- package/.docs/guides/migrations/mastra-cloud.md +6 -6
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +19 -17
- package/.docs/models/providers/deepseek.md +3 -1
- package/.docs/models/providers/openai.md +2 -0
- package/.docs/reference/configuration.md +2 -2
- 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 +2 -2
- package/.docs/reference/observability/tracing/configuration.md +3 -3
- 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 +5 -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/instances.md +2 -2
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/.docs/reference/observability/tracing/span-filtering.md +2 -2
- 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/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/CHANGELOG.md +7 -0
- package/package.json +5 -5
|
@@ -391,6 +391,14 @@ new ToolCallFilter({
|
|
|
391
391
|
})
|
|
392
392
|
```
|
|
393
393
|
|
|
394
|
+
Set `preserveModelOutput: true` to keep compact `toModelOutput` history for filtered completed tool results. The filter keeps only the model-facing output and removes raw tool args and raw results.
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
new ToolCallFilter({
|
|
398
|
+
preserveModelOutput: true,
|
|
399
|
+
})
|
|
400
|
+
```
|
|
401
|
+
|
|
394
402
|
See the [`ToolCallFilter` reference](https://mastra.ai/reference/processors/tool-call-filter) for configuration options and the [Memory Processors](https://mastra.ai/docs/memory/memory-processors) page for pre-memory filtering.
|
|
395
403
|
|
|
396
404
|
### `ToolSearchProcessor`
|
|
@@ -55,4 +55,4 @@ MASTRA_PROJECT_ID="<staging-id>" mastra studio deploy --env-file .env.staging --
|
|
|
55
55
|
MASTRA_PROJECT_ID="<production-id>" mastra studio deploy --env-file .env.production --yes
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
Each project has its own Studio URL and its own observability data. When using [`
|
|
58
|
+
Each project has its own Studio URL and its own observability data. When using [`MastraPlatformExporter`](https://mastra.ai/docs/observability/tracing/exporters/mastra-platform), set `MASTRA_PROJECT_ID` and `MASTRA_CLOUD_ACCESS_TOKEN` per environment so traces route to the matching Studio project.
|
|
@@ -75,4 +75,4 @@ Once you're ready to deploy your application to production, use [`mastra studio
|
|
|
75
75
|
|
|
76
76
|
Follow the [Studio deployment guide](https://mastra.ai/docs/studio/deployment) and [Server deployment guide](https://mastra.ai/guides/deployment/mastra-platform) for step-by-step instructions.
|
|
77
77
|
|
|
78
|
-
If you host your Mastra application on your own infrastructure, you can still send observability data to Studio using the [
|
|
78
|
+
If you host your Mastra application on your own infrastructure, you can still send observability data to Studio using the [MastraPlatformExporter](https://mastra.ai/docs/observability/tracing/exporters/mastra-platform).
|
|
@@ -35,7 +35,7 @@ You can control which log levels reach observability storage independently from
|
|
|
35
35
|
```typescript
|
|
36
36
|
import { Mastra } from '@mastra/core/mastra'
|
|
37
37
|
import { PinoLogger } from '@mastra/loggers'
|
|
38
|
-
import { Observability,
|
|
38
|
+
import { Observability, MastraStorageExporter } from '@mastra/observability'
|
|
39
39
|
|
|
40
40
|
export const mastra = new Mastra({
|
|
41
41
|
logger: new PinoLogger({ name: 'Mastra', level: 'debug' }),
|
|
@@ -43,7 +43,7 @@ export const mastra = new Mastra({
|
|
|
43
43
|
configs: {
|
|
44
44
|
default: {
|
|
45
45
|
serviceName: 'my-app',
|
|
46
|
-
exporters: [new
|
|
46
|
+
exporters: [new MastraStorageExporter()],
|
|
47
47
|
logging: {
|
|
48
48
|
enabled: true, // set to false to disable log forwarding
|
|
49
49
|
level: 'info', // minimum level: 'debug' | 'info' | 'warn' | 'error' | 'fatal'
|
|
@@ -54,7 +54,7 @@ import { Mastra } from '@mastra/core/mastra'
|
|
|
54
54
|
import { LibSQLStore } from '@mastra/libsql'
|
|
55
55
|
import { DuckDBStore } from '@mastra/duckdb'
|
|
56
56
|
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
57
|
-
import { Observability,
|
|
57
|
+
import { Observability, MastraStorageExporter, SensitiveDataFilter } from '@mastra/observability'
|
|
58
58
|
|
|
59
59
|
export const mastra = new Mastra({
|
|
60
60
|
storage: new MastraCompositeStore({
|
|
@@ -71,7 +71,7 @@ export const mastra = new Mastra({
|
|
|
71
71
|
configs: {
|
|
72
72
|
default: {
|
|
73
73
|
serviceName: 'mastra',
|
|
74
|
-
exporters: [new
|
|
74
|
+
exporters: [new MastraStorageExporter()],
|
|
75
75
|
spanOutputProcessors: [new SensitiveDataFilter()],
|
|
76
76
|
},
|
|
77
77
|
},
|
|
@@ -103,7 +103,7 @@ Mastra auto-instruments agent runs, workflow steps, tool calls, and model genera
|
|
|
103
103
|
2. **Token usage**: Extracted from the `usage` attribute on model generation spans.
|
|
104
104
|
3. **Cost estimation**: Runs each token metric through an embedded pricing registry that matches by provider and model name.
|
|
105
105
|
|
|
106
|
-
Before storage, all metric labels pass through a cardinality filter that blocks known high-cardinality values (such as trace IDs and UUIDs) to keep storage efficient. Metrics are then batched by an internal event buffer and flushed to storage by the `
|
|
106
|
+
Before storage, all metric labels pass through a cardinality filter that blocks known high-cardinality values (such as trace IDs and UUIDs) to keep storage efficient. Metrics are then batched by an internal event buffer and flushed to storage by the `MastraStorageExporter`.
|
|
107
107
|
|
|
108
108
|
## Next steps
|
|
109
109
|
|
|
@@ -111,4 +111,4 @@ Before storage, all metric labels pass through a cardinality filter that blocks
|
|
|
111
111
|
- [Tracing overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
112
112
|
- [Studio observability](https://mastra.ai/docs/studio/observability)
|
|
113
113
|
- [Observability overview](https://mastra.ai/docs/observability/overview)
|
|
114
|
-
- [
|
|
114
|
+
- [MastraStorageExporter reference](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage)
|
|
@@ -61,8 +61,8 @@ import { DuckDBStore } from '@mastra/duckdb'
|
|
|
61
61
|
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
62
62
|
import {
|
|
63
63
|
Observability,
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
MastraStorageExporter,
|
|
65
|
+
MastraPlatformExporter,
|
|
66
66
|
SensitiveDataFilter,
|
|
67
67
|
} from '@mastra/observability'
|
|
68
68
|
|
|
@@ -82,8 +82,8 @@ export const mastra = new Mastra({
|
|
|
82
82
|
default: {
|
|
83
83
|
serviceName: 'mastra',
|
|
84
84
|
exporters: [
|
|
85
|
-
new
|
|
86
|
-
new
|
|
85
|
+
new MastraStorageExporter(), // Persists observability events to Mastra Storage
|
|
86
|
+
new MastraPlatformExporter(), // Sends observability events to Mastra Platform (if MASTRA_CLOUD_ACCESS_TOKEN is set)
|
|
87
87
|
],
|
|
88
88
|
spanOutputProcessors: [
|
|
89
89
|
new SensitiveDataFilter(), // Redacts sensitive data like passwords, tokens, keys
|
|
@@ -98,9 +98,9 @@ This enables tracing, log forwarding, and metrics. Mastra also supports external
|
|
|
98
98
|
|
|
99
99
|
## Storage
|
|
100
100
|
|
|
101
|
-
Not all storage backends support every signal. Traces and logs work with most backends, but metrics require an OLAP-capable store like DuckDB (development) or ClickHouse (production). For the full compatibility list, see [storage provider support](https://mastra.ai/docs/observability/tracing/exporters/
|
|
101
|
+
Not all storage backends support every signal. Traces and logs work with most backends, but metrics require an OLAP-capable store like DuckDB (development) or ClickHouse (production). For the full compatibility list, see [storage provider support](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage).
|
|
102
102
|
|
|
103
|
-
For production environments with high traffic, use composite storage to route the observability domain to a dedicated backend. See [production recommendations](https://mastra.ai/docs/observability/tracing/exporters/
|
|
103
|
+
For production environments with high traffic, use composite storage to route the observability domain to a dedicated backend. See [production recommendations](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage) for details.
|
|
104
104
|
|
|
105
105
|
## Next steps
|
|
106
106
|
|
|
@@ -105,6 +105,43 @@ new BraintrustExporter({
|
|
|
105
105
|
})
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
+
## Attach traces to Braintrust evals
|
|
109
|
+
|
|
110
|
+
When you run Mastra inside Braintrust `Eval()` or `logger.traced()`, pass the Braintrust logger and `currentSpan` resolver to the exporter. Import `currentSpan` from the same `braintrust` package instance that creates the eval or traced span.
|
|
111
|
+
|
|
112
|
+
This helps Mastra attach its spans under the active Braintrust span when your app and `@mastra/braintrust` resolve different installed copies of the Braintrust SDK.
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { currentSpan, initLogger } from 'braintrust'
|
|
116
|
+
import { BraintrustExporter } from '@mastra/braintrust'
|
|
117
|
+
|
|
118
|
+
const logger = initLogger({
|
|
119
|
+
projectName: 'my-project',
|
|
120
|
+
apiKey: process.env.BRAINTRUST_API_KEY,
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const exporter = new BraintrustExporter({
|
|
124
|
+
braintrustLogger: logger,
|
|
125
|
+
currentSpan,
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Use the configured Mastra instance inside the Braintrust eval task. The `currentSpan` resolver above reads the active span created by `Eval()`.
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { Eval } from 'braintrust'
|
|
133
|
+
import { mastra } from '../mastra'
|
|
134
|
+
|
|
135
|
+
await Eval('my-project', {
|
|
136
|
+
data: () => [{ input: 'Say hello', expected: 'Hello' }],
|
|
137
|
+
task: async input => {
|
|
138
|
+
const agent = mastra.getAgent('assistant')
|
|
139
|
+
return (await agent.generate(input)).text
|
|
140
|
+
},
|
|
141
|
+
scores: [],
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
108
145
|
## Querying Braintrust with returned `spanId`
|
|
109
146
|
|
|
110
147
|
For Braintrust, use `spanId` as the root span identifier when searching for traces because Braintrust root-span queries are typically faster than trace-id queries.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mastra Platform exporter
|
|
2
2
|
|
|
3
|
-
The `
|
|
3
|
+
The `MastraPlatformExporter` sends traces, logs, metrics, scores, and feedback to the Mastra platform. Use it to route observability data from any Mastra app to a hosted project in the Mastra platform.
|
|
4
4
|
|
|
5
|
-
> **
|
|
5
|
+
> **Note:** `MastraPlatformExporter` was previously called `CloudExporter`. The original `CloudExporter` class is still exported from `@mastra/observability` for backward compatibility, but it is deprecated. New code should use `MastraPlatformExporter`.
|
|
6
|
+
|
|
7
|
+
> **Self-hosted or standalone apps:** If you host your Mastra application on your own infrastructure (not on Mastra Platform), you still need a deployed Studio project to view traces, logs, and metrics. `MastraPlatformExporter` sends data to a Studio project, so one must exist before you can use it.
|
|
6
8
|
>
|
|
7
9
|
> 1. [Create a Mastra project](https://mastra.ai/guides/getting-started/quickstart) if you don't have one yet.
|
|
8
10
|
> 2. [Deploy Studio](https://mastra.ai/docs/studio/deployment) to the Mastra platform with `mastra studio deploy`.
|
|
@@ -10,13 +12,13 @@ The `CloudExporter` sends traces, logs, metrics, scores, and feedback to the Mas
|
|
|
10
12
|
|
|
11
13
|
## Version compatibility
|
|
12
14
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- Starting in `@mastra/observability@1.9.2`,
|
|
15
|
+
- `MastraPlatformExporter` is available starting in `@mastra/observability@1.12.0`. In `1.8.0` through `1.11.x` the same exporter ships only as `CloudExporter`; the constructor signature and environment variables are identical.
|
|
16
|
+
- In `@mastra/observability@1.8.0` through `1.9.1`, set `MASTRA_CLOUD_TRACES_ENDPOINT=https://observability.mastra.ai` in addition to `MASTRA_CLOUD_ACCESS_TOKEN` and `MASTRA_PROJECT_ID`.
|
|
17
|
+
- Starting in `@mastra/observability@1.9.2`, the exporter defaults to `https://observability.mastra.ai`, so `MASTRA_CLOUD_TRACES_ENDPOINT` is only required when you want to send telemetry to a different collector.
|
|
16
18
|
|
|
17
19
|
## Quickstart
|
|
18
20
|
|
|
19
|
-
To connect `
|
|
21
|
+
To connect `MastraPlatformExporter`, create an access token, find the destination `projectId`, and add the exporter to your observability config.
|
|
20
22
|
|
|
21
23
|
### 1. Create an access token
|
|
22
24
|
|
|
@@ -69,7 +71,7 @@ MASTRA_PROJECT_ID=<your-project-id>
|
|
|
69
71
|
|
|
70
72
|
### 3. Set your environment variables
|
|
71
73
|
|
|
72
|
-
Set both values in your environment so `
|
|
74
|
+
Set both values in your environment so `MastraPlatformExporter` can authenticate and route telemetry to the correct project:
|
|
73
75
|
|
|
74
76
|
```bash
|
|
75
77
|
MASTRA_CLOUD_ACCESS_TOKEN=<your-cloud-access-token>
|
|
@@ -88,29 +90,29 @@ If you want to send telemetry somewhere other than Mastra platform, set `MASTRA_
|
|
|
88
90
|
MASTRA_CLOUD_TRACES_ENDPOINT=https://collector.example.com
|
|
89
91
|
```
|
|
90
92
|
|
|
91
|
-
When you pass a base origin, `
|
|
93
|
+
When you pass a base origin, `MastraPlatformExporter` derives the matching publish URLs for traces, logs, metrics, scores, and feedback automatically.
|
|
92
94
|
|
|
93
|
-
### 4. Enable `
|
|
95
|
+
### 4. Enable `MastraPlatformExporter`
|
|
94
96
|
|
|
95
|
-
The following example demonstrates how to add `
|
|
97
|
+
The following example demonstrates how to add `MastraPlatformExporter` to your observability config:
|
|
96
98
|
|
|
97
99
|
```ts
|
|
98
100
|
import { Mastra } from '@mastra/core'
|
|
99
|
-
import { Observability,
|
|
101
|
+
import { Observability, MastraPlatformExporter } from '@mastra/observability'
|
|
100
102
|
|
|
101
103
|
export const mastra = new Mastra({
|
|
102
104
|
observability: new Observability({
|
|
103
105
|
configs: {
|
|
104
106
|
production: {
|
|
105
107
|
serviceName: 'api-server',
|
|
106
|
-
exporters: [new
|
|
108
|
+
exporters: [new MastraPlatformExporter()],
|
|
107
109
|
},
|
|
108
110
|
},
|
|
109
111
|
}),
|
|
110
112
|
})
|
|
111
113
|
```
|
|
112
114
|
|
|
113
|
-
Set `serviceName` on the observability config, not on `
|
|
115
|
+
Set `serviceName` on the observability config, not on `MastraPlatformExporter` itself.
|
|
114
116
|
|
|
115
117
|
Use a stable `serviceName` value. In Studio, traces can be filtered by **Deployments → Service Name**, so a consistent name makes traces easier to find.
|
|
116
118
|
|
|
@@ -119,23 +121,23 @@ Visit [Observability configuration reference](https://mastra.ai/reference/observ
|
|
|
119
121
|
If you prefer, rely entirely on environment variables:
|
|
120
122
|
|
|
121
123
|
```ts
|
|
122
|
-
new
|
|
124
|
+
new MastraPlatformExporter()
|
|
123
125
|
```
|
|
124
126
|
|
|
125
|
-
With `MASTRA_CLOUD_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` set, `
|
|
127
|
+
With `MASTRA_CLOUD_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` set, `MastraPlatformExporter` sends data to the Mastra platform project you configured. If you also set `MASTRA_CLOUD_TRACES_ENDPOINT`, it sends data to that collector instead.
|
|
126
128
|
|
|
127
|
-
> **Note:** Visit [
|
|
129
|
+
> **Note:** Visit [MastraPlatformExporter reference](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter) for the full list of configuration options.
|
|
128
130
|
|
|
129
131
|
## Recommended configuration
|
|
130
132
|
|
|
131
|
-
Include `
|
|
133
|
+
Include `MastraStorageExporter` if you also want to inspect local traces in Studio or persist observability data to your configured storage.
|
|
132
134
|
|
|
133
135
|
```ts
|
|
134
136
|
import { Mastra } from '@mastra/core'
|
|
135
137
|
import {
|
|
136
138
|
Observability,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
MastraStorageExporter,
|
|
140
|
+
MastraPlatformExporter,
|
|
139
141
|
SensitiveDataFilter,
|
|
140
142
|
} from '@mastra/observability'
|
|
141
143
|
|
|
@@ -144,7 +146,7 @@ export const mastra = new Mastra({
|
|
|
144
146
|
configs: {
|
|
145
147
|
default: {
|
|
146
148
|
serviceName: 'mastra',
|
|
147
|
-
exporters: [new
|
|
149
|
+
exporters: [new MastraStorageExporter(), new MastraPlatformExporter()],
|
|
148
150
|
spanOutputProcessors: [new SensitiveDataFilter()],
|
|
149
151
|
},
|
|
150
152
|
},
|
|
@@ -154,7 +156,7 @@ export const mastra = new Mastra({
|
|
|
154
156
|
|
|
155
157
|
## Complete configuration
|
|
156
158
|
|
|
157
|
-
`
|
|
159
|
+
`MastraPlatformExporter` defaults to Mastra platform. If you want to send telemetry to a different collector, set `MASTRA_CLOUD_TRACES_ENDPOINT` in your environment or pass `endpoint` in code.
|
|
158
160
|
|
|
159
161
|
```bash
|
|
160
162
|
MASTRA_CLOUD_TRACES_ENDPOINT=https://collector.example.com
|
|
@@ -163,7 +165,7 @@ MASTRA_CLOUD_TRACES_ENDPOINT=https://collector.example.com
|
|
|
163
165
|
The following example demonstrates how to override the collector endpoint and batching behavior in code:
|
|
164
166
|
|
|
165
167
|
```ts
|
|
166
|
-
new
|
|
168
|
+
new MastraPlatformExporter({
|
|
167
169
|
endpoint: 'https://collector.example.com',
|
|
168
170
|
maxBatchSize: 1000,
|
|
169
171
|
maxBatchWaitMs: 5000,
|
|
@@ -173,7 +175,7 @@ new CloudExporter({
|
|
|
173
175
|
|
|
174
176
|
## Viewing data in Mastra Studio
|
|
175
177
|
|
|
176
|
-
After you enable `
|
|
178
|
+
After you enable `MastraPlatformExporter`, open your project in [Mastra Studio](https://projects.mastra.ai) to inspect the exported data.
|
|
177
179
|
|
|
178
180
|
- Open the project you set `MASTRA_PROJECT_ID` to and select **Open Studio**.
|
|
179
181
|
- In Studio, go to **Traces** to inspect agent and workflow traces.
|
|
@@ -184,7 +186,7 @@ When you deploy with Mastra Studio, set **Deployment → Service Name** to a sta
|
|
|
184
186
|
|
|
185
187
|
## Performance
|
|
186
188
|
|
|
187
|
-
> **Info:**
|
|
189
|
+
> **Info:** MastraPlatformExporter uses batching to optimize network usage. Events are buffered and sent in batches, reducing overhead while maintaining near real-time visibility.
|
|
188
190
|
|
|
189
191
|
### Batching behavior
|
|
190
192
|
|
|
@@ -196,4 +198,4 @@ When you deploy with Mastra Studio, set **Deployment → Service Name** to a sta
|
|
|
196
198
|
## Related
|
|
197
199
|
|
|
198
200
|
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
199
|
-
- [
|
|
201
|
+
- [MastraStorageExporter](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage)
|
|
@@ -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,7 +169,7 @@ 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
|
|
@@ -213,22 +215,22 @@ class DropAlertExporter extends BaseExporter {
|
|
|
213
215
|
|
|
214
216
|
```typescript
|
|
215
217
|
// Zero config - recommended for most users
|
|
216
|
-
new
|
|
218
|
+
new MastraStorageExporter()
|
|
217
219
|
|
|
218
220
|
// Development override
|
|
219
|
-
new
|
|
221
|
+
new MastraStorageExporter({
|
|
220
222
|
strategy: 'realtime', // Immediate visibility for debugging
|
|
221
223
|
})
|
|
222
224
|
|
|
223
225
|
// High-throughput production
|
|
224
|
-
new
|
|
226
|
+
new MastraStorageExporter({
|
|
225
227
|
maxBatchSize: 2000, // Larger batches
|
|
226
228
|
maxBatchWaitMs: 10000, // Wait longer to fill batches
|
|
227
229
|
maxBufferSize: 50000, // Handle longer outages
|
|
228
230
|
})
|
|
229
231
|
|
|
230
232
|
// Low-latency production
|
|
231
|
-
new
|
|
233
|
+
new MastraStorageExporter({
|
|
232
234
|
maxBatchSize: 100, // Smaller batches
|
|
233
235
|
maxBatchWaitMs: 1000, // Flush quickly
|
|
234
236
|
})
|
|
@@ -237,6 +239,6 @@ new DefaultExporter({
|
|
|
237
239
|
## Related
|
|
238
240
|
|
|
239
241
|
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
240
|
-
- [
|
|
242
|
+
- [MastraPlatformExporter](https://mastra.ai/docs/observability/tracing/exporters/mastra-platform)
|
|
241
243
|
- [Composite Storage](https://mastra.ai/reference/storage/composite): Combine multiple storage providers
|
|
242
244
|
- [Storage Configuration](https://mastra.ai/docs/memory/storage)
|
|
@@ -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'
|
|
@@ -295,8 +296,8 @@ export const mastra = new Mastra({
|
|
|
295
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
|