@mastra/mcp-docs-server 1.1.45 → 1.1.46-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.docs/docs/agents/code-mode.md +2 -0
  2. package/.docs/docs/agents/signal-providers.md +222 -0
  3. package/.docs/docs/agents/signals.md +64 -190
  4. package/.docs/docs/getting-started/build-with-ai.md +2 -2
  5. package/.docs/docs/mastra-platform/configuration.md +1 -1
  6. package/.docs/docs/mastra-platform/overview.md +1 -1
  7. package/.docs/docs/observability/config.md +139 -0
  8. package/.docs/docs/observability/{tracing → integrations}/bridges/datadog.md +7 -7
  9. package/.docs/docs/observability/{tracing → integrations}/bridges/otel.md +3 -3
  10. package/.docs/docs/observability/{tracing → integrations}/exporters/datadog.md +1 -1
  11. package/.docs/docs/observability/{tracing → integrations}/exporters/mastra-platform.md +1 -1
  12. package/.docs/docs/observability/{tracing → integrations}/exporters/mastra-storage.md +1 -1
  13. package/.docs/docs/observability/{tracing → integrations}/exporters/otel.md +4 -4
  14. package/.docs/docs/observability/{tracing → integrations}/exporters/posthog.md +16 -0
  15. package/.docs/docs/observability/integrations/overview.md +45 -0
  16. package/.docs/docs/observability/metrics/overview.md +1 -1
  17. package/.docs/docs/observability/metrics/querying.md +18 -0
  18. package/.docs/docs/observability/overview.md +8 -4
  19. package/.docs/docs/observability/storage.md +79 -0
  20. package/.docs/docs/observability/tracing/overview.md +98 -390
  21. package/.docs/guides/guide/signal-provider.md +217 -0
  22. package/.docs/guides/migrations/upgrade-to-v1/tracing.md +11 -11
  23. package/.docs/reference/agents/agent.md +150 -2
  24. package/.docs/reference/client-js/agents.md +4 -0
  25. package/.docs/reference/core/mastra-class.md +28 -0
  26. package/.docs/reference/harness/harness-class.md +1 -1
  27. package/.docs/reference/index.md +3 -0
  28. package/.docs/reference/observability/tracing/bridges/datadog.md +2 -2
  29. package/.docs/reference/observability/tracing/bridges/otel.md +2 -2
  30. package/.docs/reference/observability/tracing/configuration.md +1 -1
  31. package/.docs/reference/observability/tracing/exporters/arize.md +1 -1
  32. package/.docs/reference/observability/tracing/exporters/arthur.md +1 -1
  33. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +1 -1
  34. package/.docs/reference/observability/tracing/exporters/console-exporter.md +1 -1
  35. package/.docs/reference/observability/tracing/exporters/default-exporter.md +1 -1
  36. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +1 -1
  37. package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +1 -1
  38. package/.docs/reference/observability/tracing/exporters/otel.md +2 -2
  39. package/.docs/reference/observability/tracing/span-filtering.md +1 -1
  40. package/.docs/reference/pubsub/base.md +24 -0
  41. package/.docs/reference/pubsub/caching-pubsub.md +6 -0
  42. package/.docs/reference/pubsub/event-emitter.md +36 -1
  43. package/.docs/reference/signals/create-notification-inbox-tool.md +67 -0
  44. package/.docs/reference/signals/signal-provider.md +406 -0
  45. package/.docs/reference/signals/webhook-signal-provider.md +137 -0
  46. package/.docs/reference/storage/clickhouse.md +3 -3
  47. package/.docs/reference/storage/composite.md +1 -1
  48. package/.docs/reference/storage/duckdb.md +1 -1
  49. package/.docs/reference/storage/libsql.md +1 -1
  50. package/.docs/reference/storage/postgresql.md +1 -1
  51. package/CHANGELOG.md +15 -0
  52. package/package.json +7 -7
  53. /package/.docs/docs/observability/{tracing → integrations}/exporters/arize.md +0 -0
  54. /package/.docs/docs/observability/{tracing → integrations}/exporters/arthur.md +0 -0
  55. /package/.docs/docs/observability/{tracing → integrations}/exporters/braintrust.md +0 -0
  56. /package/.docs/docs/observability/{tracing → integrations}/exporters/laminar.md +0 -0
  57. /package/.docs/docs/observability/{tracing → integrations}/exporters/langfuse.md +0 -0
  58. /package/.docs/docs/observability/{tracing → integrations}/exporters/langsmith.md +0 -0
  59. /package/.docs/docs/observability/{tracing → integrations}/exporters/sentry.md +0 -0
  60. /package/.docs/docs/observability/{tracing → integrations}/processors/sensitive-data-filter.md +0 -0
@@ -32,4 +32,4 @@ Once you're ready to deploy your application to production, use [`mastra studio
32
32
 
33
33
  Follow the [Studio on Mastra platform](https://mastra.ai/docs/mastra-platform/studio) and [Server on Mastra platform](https://mastra.ai/docs/mastra-platform/server) docs for step-by-step instructions.
34
34
 
35
- If you host your Mastra application on your own infrastructure, you can still send observability data to Mastra platform using the [MastraPlatformExporter](https://mastra.ai/docs/observability/tracing/exporters/mastra-platform).
35
+ If you host your Mastra application on your own infrastructure, you can still send observability data to Mastra platform using the [MastraPlatformExporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-platform).
@@ -0,0 +1,139 @@
1
+ # Configuration
2
+
3
+ Observability is configured once on your Mastra instance and applies across traces, logs, and metrics.
4
+
5
+ ## When to use configuration
6
+
7
+ - Set up a default observability pipeline for local development.
8
+ - Route different environments or request types to different observability configs.
9
+ - Keep Mastra Studio and Mastra platform access enabled while also sending data to external providers.
10
+
11
+ ## Quickstart
12
+
13
+ The following example demonstrates the standard starter setup: composite storage with DuckDB for the observability domain, plus Mastra storage, Mastra platform, and sensitive-data redaction.
14
+
15
+ ```ts
16
+ import { Mastra } from '@mastra/core/mastra'
17
+ import { MastraCompositeStore } from '@mastra/core/storage'
18
+ import { DuckDBStore } from '@mastra/duckdb'
19
+ import { LibSQLStore } from '@mastra/libsql'
20
+ import {
21
+ Observability,
22
+ MastraStorageExporter,
23
+ MastraPlatformExporter,
24
+ SensitiveDataFilter,
25
+ } from '@mastra/observability'
26
+
27
+ export const mastra = new Mastra({
28
+ storage: new MastraCompositeStore({
29
+ id: 'composite-storage',
30
+ default: new LibSQLStore({
31
+ id: 'mastra-storage',
32
+ url: 'file:./mastra.db',
33
+ }),
34
+ domains: {
35
+ observability: await new DuckDBStore().getStore('observability'),
36
+ },
37
+ }),
38
+ observability: new Observability({
39
+ configs: {
40
+ default: {
41
+ serviceName: 'mastra',
42
+ exporters: [new MastraStorageExporter(), new MastraPlatformExporter()],
43
+ spanOutputProcessors: [new SensitiveDataFilter()],
44
+ logging: {
45
+ enabled: true,
46
+ level: 'info',
47
+ },
48
+ },
49
+ },
50
+ }),
51
+ })
52
+ ```
53
+
54
+ ## Basic config
55
+
56
+ An observability config usually contains:
57
+
58
+ - `serviceName`: The service identifier attached to exported observability data.
59
+ - `exporters`: One or more destinations for traces, logs, and derived metrics.
60
+ - `spanOutputProcessors`: Transformations that run before spans are exported.
61
+ - `logging`: Log forwarding settings for observability storage.
62
+
63
+ For destinations and processors, see [Integrations overview](https://mastra.ai/docs/observability/integrations/overview).
64
+
65
+ ## Maintaining Studio access
66
+
67
+ When you add external exporters, keep `MastraStorageExporter` for Studio observability and/or `MastraPlatformExporter` for hosted Mastra platform observability.
68
+
69
+ This example shows only the observability config. Configure storage separately.
70
+
71
+ ```ts
72
+ import { Observability, MastraStorageExporter, MastraPlatformExporter } from '@mastra/observability'
73
+ import { ArizeExporter } from '@mastra/arize'
74
+
75
+ export const observability = new Observability({
76
+ configs: {
77
+ production: {
78
+ serviceName: 'my-service',
79
+ exporters: [
80
+ new ArizeExporter({
81
+ endpoint: process.env.PHOENIX_COLLECTOR_ENDPOINT,
82
+ apiKey: process.env.PHOENIX_API_KEY,
83
+ }),
84
+ new MastraStorageExporter(),
85
+ new MastraPlatformExporter(),
86
+ ],
87
+ },
88
+ },
89
+ })
90
+ ```
91
+
92
+ ## Flushing in serverless environments
93
+
94
+ In serverless environments, flush observability exporters before the runtime pauses or exits:
95
+
96
+ ```ts
97
+ const observability = mastra.getObservability()
98
+ await observability.flush()
99
+ ```
100
+
101
+ Use external storage in serverless environments instead of local file storage. For storage selection and routing, see [Storage](https://mastra.ai/docs/observability/storage).
102
+
103
+ ## Multi-config setup
104
+
105
+ Use multiple configs when different environments or request types need different exporters or sampling behavior. Select the active config at runtime with `configSelector`.
106
+
107
+ ```ts
108
+ import { Mastra } from '@mastra/core'
109
+ import { Observability, MastraStorageExporter } from '@mastra/observability'
110
+ import { LangfuseExporter } from '@mastra/langfuse'
111
+
112
+ const storageExporter = new MastraStorageExporter()
113
+ const langfuseExporter = new LangfuseExporter()
114
+
115
+ export const mastra = new Mastra({
116
+ observability: new Observability({
117
+ configs: {
118
+ development: {
119
+ serviceName: 'my-service-dev',
120
+ exporters: [storageExporter],
121
+ },
122
+ production: {
123
+ serviceName: 'my-service-prod',
124
+ exporters: [storageExporter, langfuseExporter],
125
+ },
126
+ },
127
+ configSelector: () => process.env.NODE_ENV || 'development',
128
+ }),
129
+ })
130
+ ```
131
+
132
+ For trace sampling, see [Tracing](https://mastra.ai/docs/observability/tracing/overview).
133
+
134
+ ## Related
135
+
136
+ - [Observability overview](https://mastra.ai/docs/observability/overview)
137
+ - [Storage](https://mastra.ai/docs/observability/storage)
138
+ - [Tracing](https://mastra.ai/docs/observability/tracing/overview)
139
+ - [Integrations overview](https://mastra.ai/docs/observability/integrations/overview)
@@ -4,7 +4,7 @@
4
4
 
5
5
  The Datadog Bridge enables bidirectional integration between Mastra's tracing system and Datadog. Unlike exporters that send trace data after execution completes, the bridge creates native dd-trace spans in real time so that auto-instrumented APM operations (HTTP calls, database queries, etc.) inside your tools and processors are correctly nested under their parent Mastra spans.
6
6
 
7
- > **Not using dd-trace APM?:** If you only need to send LLM Observability data and don't use `dd-trace` APM auto-instrumentation, the [Datadog Exporter](https://mastra.ai/docs/observability/tracing/exporters/datadog) is simpler — it supports agentless mode and sends spans directly to Datadog without a local agent.
7
+ > **Not using dd-trace APM?:** If you only need to send LLM Observability data and don't use `dd-trace` APM auto-instrumentation, the [Datadog Exporter](https://mastra.ai/docs/observability/integrations/exporters/datadog) is simpler — it supports agentless mode and sends spans directly to Datadog without a local agent.
8
8
 
9
9
  ## When to use the bridge
10
10
 
@@ -30,7 +30,7 @@ The DatadogBridge participates in two parts of the dd-trace pipeline:
30
30
 
31
31
  - Emits annotations (model info, token usage, input/output, errors) through `dd-trace`'s LLM Observability pipeline
32
32
  - Maintains parent-child relationships in Datadog LLM Observability using nested `llmobs.trace()` calls
33
- - Reuses the same data shape and span-kind mapping as the [Datadog Exporter](https://mastra.ai/docs/observability/tracing/exporters/datadog)
33
+ - Reuses the same data shape and span-kind mapping as the [Datadog Exporter](https://mastra.ai/docs/observability/integrations/exporters/datadog)
34
34
 
35
35
  ## Why this matters
36
36
 
@@ -64,7 +64,7 @@ yarn add @mastra/datadog dd-trace
64
64
  bun add @mastra/datadog dd-trace
65
65
  ```
66
66
 
67
- The bridge requires `dd-trace` to be installed and a local Datadog Agent (or compatible OTLP receiver) to receive APM data. See the [APM prerequisites](https://mastra.ai/docs/observability/tracing/exporters/datadog) on the exporter page for agent setup details.
67
+ The bridge requires `dd-trace` to be installed and a local Datadog Agent (or compatible OTLP receiver) to receive APM data. See the [APM prerequisites](https://mastra.ai/docs/observability/integrations/exporters/datadog) on the exporter page for agent setup details.
68
68
 
69
69
  ## Configuration
70
70
 
@@ -148,7 +148,7 @@ new DatadogBridge({
148
148
  })
149
149
  ```
150
150
 
151
- > **Note:** For most bridge users, agent mode is the right choice. APM data cannot be sent in agentless mode, so enabling agentless splits LLM Observability traffic away from APM traffic. If you want LLM Observability only without an agent, use the [Datadog Exporter](https://mastra.ai/docs/observability/tracing/exporters/datadog) instead.
151
+ > **Note:** For most bridge users, agent mode is the right choice. APM data cannot be sent in agentless mode, so enabling agentless splits LLM Observability traffic away from APM traffic. If you want LLM Observability only without an agent, use the [Datadog Exporter](https://mastra.ai/docs/observability/integrations/exporters/datadog) instead.
152
152
 
153
153
  ## Trace hierarchy
154
154
 
@@ -168,7 +168,7 @@ In Datadog, the APM trace shows this full topology, and the LLM Observability pr
168
168
 
169
169
  ## Span type mapping
170
170
 
171
- The bridge uses the same span-kind mapping as the Datadog Exporter for LLM Observability. See [span type mapping](https://mastra.ai/docs/observability/tracing/exporters/datadog) on the exporter page.
171
+ The bridge uses the same span-kind mapping as the Datadog Exporter for LLM Observability. See [span type mapping](https://mastra.ai/docs/observability/integrations/exporters/datadog) on the exporter page.
172
172
 
173
173
  ## Using tags
174
174
 
@@ -206,12 +206,12 @@ If APM spans aren't connecting to Mastra spans as expected:
206
206
  - Ensure the DatadogBridge is set as `bridge` (not as an entry in `exporters`) in your observability config
207
207
  - Confirm you haven't also added the `DatadogExporter` to `exporters` — using both will double-emit LLM Observability data
208
208
 
209
- For native-module compatibility issues with `dd-trace` and bundler externals, see the [Datadog exporter troubleshooting](https://mastra.ai/docs/observability/tracing/exporters/datadog) section.
209
+ For native-module compatibility issues with `dd-trace` and bundler externals, see the [Datadog exporter troubleshooting](https://mastra.ai/docs/observability/integrations/exporters/datadog) section.
210
210
 
211
211
  ## Related
212
212
 
213
213
  - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
214
- - [Datadog Exporter](https://mastra.ai/docs/observability/tracing/exporters/datadog) - LLM Observability only, no `dd-trace` APM
214
+ - [Datadog Exporter](https://mastra.ai/docs/observability/integrations/exporters/datadog) - LLM Observability only, no `dd-trace` APM
215
215
  - [DatadogBridge Reference](https://mastra.ai/reference/observability/tracing/bridges/datadog) - API documentation
216
216
  - [Datadog APM documentation](https://docs.datadoghq.com/tracing/)
217
217
  - [Datadog LLM Observability documentation](https://docs.datadoghq.com/llm_observability/)
@@ -4,7 +4,7 @@
4
4
 
5
5
  The OpenTelemetry (OTEL) Bridge enables bidirectional integration between Mastra's tracing system and existing OpenTelemetry infrastructure. Unlike exporters that send trace data to external platforms, the bridge creates native OTEL spans that participate in your distributed tracing context.
6
6
 
7
- > **Looking to send traces without existing OTEL infrastructure?:** If you don't have existing OpenTelemetry instrumentation, the [OpenTelemetry Exporter](https://mastra.ai/docs/observability/tracing/exporters/otel) may be simpler — it sends traces directly without requiring an OTEL SDK setup.
7
+ > **Looking to send traces without existing OTEL infrastructure?:** If you don't have existing OpenTelemetry instrumentation, the [OpenTelemetry Exporter](https://mastra.ai/docs/observability/integrations/exporters/otel) may be simpler — it sends traces directly without requiring an OTEL SDK setup.
8
8
 
9
9
  ## When to use the bridge
10
10
 
@@ -167,7 +167,7 @@ tsx --import ./instrumentation.ts ./src/index.ts
167
167
 
168
168
  The OtelBridge exports Mastra spans using [OpenTelemetry Semantic Conventions for GenAI v1.38.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.38.0/docs/gen-ai). This includes standardized span names (`chat {model}`, `execute_tool {tool_name}`, etc.) and attributes (`gen_ai.usage.input_tokens`, `gen_ai.request.model`, etc.).
169
169
 
170
- For details on span naming and attributes, see the [OpenTelemetry Exporter semantic conventions](https://mastra.ai/docs/observability/tracing/exporters/otel).
170
+ For details on span naming and attributes, see the [OpenTelemetry Exporter semantic conventions](https://mastra.ai/docs/observability/integrations/exporters/otel).
171
171
 
172
172
  ## Trace hierarchy
173
173
 
@@ -230,5 +230,5 @@ If traces aren't displaying or connecting as expected:
230
230
  ## Related
231
231
 
232
232
  - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
233
- - [OpenTelemetry Exporter](https://mastra.ai/docs/observability/tracing/exporters/otel): For sending traces to OTEL backends
233
+ - [OpenTelemetry Exporter](https://mastra.ai/docs/observability/integrations/exporters/otel): For sending traces to OTEL backends
234
234
  - [OtelBridge Reference](https://mastra.ai/reference/observability/tracing/bridges/otel): API documentation
@@ -2,7 +2,7 @@
2
2
 
3
3
  [Datadog](https://datadoghq.com/) is a comprehensive monitoring platform with dedicated LLM Observability features. The Datadog exporter sends your traces to Datadog's LLM Observability product, providing insights into model performance, token usage, and conversation flows.
4
4
 
5
- > **Also using dd-trace APM?:** If you also use `dd-trace` APM auto-instrumentation, consider the [Datadog Bridge](https://mastra.ai/docs/observability/tracing/bridges/datadog) instead. The bridge creates `dd-trace` spans in real time so HTTP and database calls inside tools and processors are correctly nested under their parent Mastra span. The exporter on its own sends LLM Observability data after execution completes, which means auto-instrumented APM spans fall back to the request handler.
5
+ > **Also using dd-trace APM?:** If you also use `dd-trace` APM auto-instrumentation, consider the [Datadog Bridge](https://mastra.ai/docs/observability/integrations/bridges/datadog) instead. The bridge creates `dd-trace` spans in real time so HTTP and database calls inside tools and processors are correctly nested under their parent Mastra span. The exporter on its own sends LLM Observability data after execution completes, which means auto-instrumented APM spans fall back to the request handler.
6
6
 
7
7
  ## Installation
8
8
 
@@ -198,4 +198,4 @@ When you deploy with Mastra Studio, set **Deployment → Service Name** to a sta
198
198
  ## Related
199
199
 
200
200
  - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
201
- - [MastraStorageExporter](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage)
201
+ - [MastraStorageExporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
@@ -239,6 +239,6 @@ new MastraStorageExporter({
239
239
  ## Related
240
240
 
241
241
  - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
242
- - [MastraPlatformExporter](https://mastra.ai/docs/observability/tracing/exporters/mastra-platform)
242
+ - [MastraPlatformExporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-platform)
243
243
  - [Composite Storage](https://mastra.ai/reference/storage/composite): Combine multiple storage providers
244
244
  - [Storage Configuration](https://mastra.ai/docs/memory/storage)
@@ -2,7 +2,7 @@
2
2
 
3
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
- > **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.
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/integrations/bridges/otel) instead.
6
6
 
7
7
  ## Installation
8
8
 
@@ -313,7 +313,7 @@ new OtelExporter({
313
313
  })
314
314
  ```
315
315
 
316
- > **Laminar-Native Exporter:** For Laminar-specific features like native span paths, metadata, and tags rendering in the Laminar dashboard, consider using the dedicated [`@mastra/laminar`](https://mastra.ai/docs/observability/tracing/exporters/laminar) exporter instead. It provides optimized integration with Laminar's platform.
316
+ > **Laminar-Native Exporter:** For Laminar-specific features like native span paths, metadata, and tags rendering in the Laminar dashboard, consider using the dedicated [`@mastra/laminar`](https://mastra.ai/docs/observability/integrations/exporters/laminar) exporter instead. It provides optimized integration with Laminar's platform.
317
317
 
318
318
  ### Datadog
319
319
 
@@ -369,7 +369,7 @@ export const mastra = new Mastra({
369
369
 
370
370
  > **Warning:** The explicit imports of `@grpc/grpc-js` and `@opentelemetry/exporter-trace-otlp-grpc` at the top of the file, along with the [`bundler.externals`](https://mastra.ai/reference/configuration) configuration, are required for the gRPC transport to work correctly. Without these, you may encounter connection issues.
371
371
 
372
- > **Datadog-Native Exporter:** For Datadog-specific features like automatic span type mapping, LLM span categorization, and simplified setup without gRPC configuration, consider using the dedicated [`@mastra/datadog`](https://mastra.ai/docs/observability/tracing/exporters/datadog) exporter instead. It provides optimized integration with Datadog's APM platform.
372
+ > **Datadog-Native Exporter:** For Datadog-specific features like automatic span type mapping, LLM span categorization, and simplified setup without gRPC configuration, consider using the dedicated [`@mastra/datadog`](https://mastra.ai/docs/observability/integrations/exporters/datadog) exporter instead. It provides optimized integration with Datadog's APM platform.
373
373
 
374
374
  ### Custom/Generic OTEL Endpoints
375
375
 
@@ -548,6 +548,6 @@ Install the suggested package for your provider.
548
548
  ## Related
549
549
 
550
550
  - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
551
- - [OpenTelemetry Bridge](https://mastra.ai/docs/observability/tracing/bridges/otel)
551
+ - [OpenTelemetry Bridge](https://mastra.ai/docs/observability/integrations/bridges/otel)
552
552
  - [OpenTelemetry Semantic Conventions for GenAI v1.38.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.38.0/docs/gen-ai)
553
553
  - [OTEL Exporter Reference](https://mastra.ai/reference/observability/tracing/exporters/otel)
@@ -142,6 +142,22 @@ new PosthogExporter({
142
142
  })
143
143
  ```
144
144
 
145
+ ### Group analytics
146
+
147
+ To attach events to a [PostHog group](https://posthog.com/docs/product-analytics/group-analytics), add a `$groups` object to `tracingOptions.metadata`. The exporter sends those values as the top-level `groups` field on the PostHog capture call, so you can slice analytics such as LLM cost by group.
148
+
149
+ ```ts
150
+ await agent.generate(input, {
151
+ tracingOptions: {
152
+ metadata: {
153
+ $groups: {
154
+ publication: 'publication-1',
155
+ },
156
+ },
157
+ },
158
+ })
159
+ ```
160
+
145
161
  ## Related
146
162
 
147
163
  - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
@@ -0,0 +1,45 @@
1
+ # Integrations overview
2
+
3
+ Mastra observability integrations control where observability data goes and how it is transformed on the way out. Use integrations to store data in Mastra storage, send it to Mastra platform, connect to external observability providers, or redact exported span data.
4
+
5
+ ## When to use integrations
6
+
7
+ - Keep observability available in Studio with `MastraStorageExporter`.
8
+ - Send hosted observability data to Mastra platform with `MastraPlatformExporter`.
9
+ - Forward traces to external providers such as Datadog, Langfuse, or OpenTelemetry backends.
10
+ - Redact sensitive values before they leave the runtime.
11
+
12
+ ## Choose an integration path
13
+
14
+ - Studio workflow: Start with [Mastra Storage](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage).
15
+ - Hosted Mastra workflow: Add [Mastra platform](https://mastra.ai/docs/observability/integrations/exporters/mastra-platform).
16
+ - External observability stack: Choose one or more exporter pages under the sidebar `Exporters` section.
17
+ - Existing distributed trace context: Use a bridge, then add exporters as needed.
18
+
19
+ ## Exporters
20
+
21
+ Exporters send observability data to a destination:
22
+
23
+ - [Mastra Storage](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage): Persist observability data for Studio.
24
+ - [Mastra platform](https://mastra.ai/docs/observability/integrations/exporters/mastra-platform): Send hosted observability data to Mastra platform.
25
+ - External providers: Use exporter pages for Datadog, Langfuse, OpenTelemetry, and other supported platforms.
26
+
27
+ ## Bridges
28
+
29
+ Bridges connect Mastra to an existing distributed tracing context:
30
+
31
+ - [OpenTelemetry bridge](https://mastra.ai/docs/observability/integrations/bridges/otel): Integrate Mastra with an existing OpenTelemetry trace.
32
+ - [Datadog bridge](https://mastra.ai/docs/observability/integrations/bridges/datadog): Integrate Mastra with Datadog tracing and LLM Observability flows.
33
+
34
+ ## Processors
35
+
36
+ Processors transform or redact spans before export:
37
+
38
+ - [Sensitive Data Filter](https://mastra.ai/docs/observability/integrations/processors/sensitive-data-filter): Redact sensitive fields before spans leave the runtime.
39
+
40
+ ## Next steps
41
+
42
+ - [Configuration](https://mastra.ai/docs/observability/config)
43
+ - [Tracing](https://mastra.ai/docs/observability/tracing/overview)
44
+ - [Mastra Storage](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
45
+ - [OpenTelemetry bridge](https://mastra.ai/docs/observability/integrations/bridges/otel)
@@ -114,4 +114,4 @@ Before storage, all metric labels pass through a cardinality filter that blocks
114
114
  - [Tracing overview](https://mastra.ai/docs/observability/tracing/overview)
115
115
  - [Studio observability](https://mastra.ai/docs/studio/observability)
116
116
  - [Observability overview](https://mastra.ai/docs/observability/overview)
117
- - [MastraStorageExporter reference](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage)
117
+ - [MastraStorageExporter reference](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
@@ -241,6 +241,24 @@ curl -sS -X POST http://localhost:4111/api/observability/metrics/aggregate \
241
241
  -d '{"name":["mastra_tool_duration_ms"],"aggregation":"avg","filters":{"entityName":"weatherTool","labels":{"status":"error"}}}'
242
242
  ```
243
243
 
244
+ ### Always provide a time range
245
+
246
+ `filters.timestamp` is optional, but you should treat it as required for any query that runs against a production store. Observability tables are typically partitioned (or chunked, for TimescaleDB) by event time. When you supply `timestamp.start` (and ideally `end`), the backend can prune to the partitions that overlap the range — usually one or two. Without a time range, the planner has to scan every partition, which can be hundreds of segments over a year of retention and is the most common cause of slow OLAP queries on Postgres-backed stores.
247
+
248
+ A safe default for ad-hoc queries is the last 24 hours; alerts and dashboards should match their actual evaluation window:
249
+
250
+ ```typescript
251
+ await observability!.getMetricAggregate({
252
+ name: ['mastra_agent_duration_ms'],
253
+ aggregation: 'p95',
254
+ filters: {
255
+ timestamp: { start: new Date(Date.now() - 24 * 60 * 60 * 1000) },
256
+ },
257
+ })
258
+ ```
259
+
260
+ This guidance applies to all backends (ClickHouse, Postgres v-next, DuckDB), but matters most for Postgres v-next where each missing time bound translates directly into one extra partition scan.
261
+
244
262
  ## Example: build a custom KPI tile
245
263
 
246
264
  The following tool returns input-token volume and estimated cost for the last hour. An agent or a dashboard can call it as `structuredContent` without re-implementing the query.
@@ -2,9 +2,12 @@
2
2
 
3
3
  Mastra's observability system gives you visibility into every agent run, workflow step, tool call, and model interaction. Agent behavior depends on model responses, prompts, tools, memory, and workflow state, so observability helps you inspect runtime decisions from day one. It captures three complementary signals that work together to help you understand what your application is doing and why.
4
4
 
5
+ - [**Configuration**](https://mastra.ai/docs/observability/config): Configure observability once for traces, logs, and metrics.
6
+ - [**Storage**](https://mastra.ai/docs/observability/storage): Choose storage backends for persisted traces, logs, and metrics aggregation.
5
7
  - [**Tracing**](https://mastra.ai/docs/observability/tracing/overview): Records every operation as a hierarchical timeline of spans, capturing inputs, outputs, token usage, and timing.
6
8
  - [**Logging**](https://mastra.ai/docs/observability/logging): Forwards structured log entries from your application and Mastra internals to observability storage, correlated to traces automatically.
7
9
  - [**Metrics**](https://mastra.ai/docs/observability/metrics/overview): Extracts duration, token usage, and cost data from traces automatically, with no additional instrumentation required.
10
+ - [**Integrations**](https://mastra.ai/docs/observability/integrations/overview): Choose exporters, bridges, and span processors for Studio, hosted, or external observability workflows.
8
11
 
9
12
  ## When to use observability
10
13
 
@@ -94,7 +97,7 @@ export const mastra = new Mastra({
94
97
  })
95
98
  ```
96
99
 
97
- This enables tracing, log forwarding, and metrics. Mastra also supports external tracing providers like Langfuse, Datadog, and any OpenTelemetry-compatible platform. See [Tracing](https://mastra.ai/docs/observability/tracing/overview) for configuration details.
100
+ This enables tracing, log forwarding, and metrics. Mastra also supports external tracing providers like Langfuse, Datadog, and any OpenTelemetry-compatible platform. Use [Configuration](https://mastra.ai/docs/observability/config), [Storage](https://mastra.ai/docs/observability/storage), and [Integrations overview](https://mastra.ai/docs/observability/integrations/overview) to set up observability.
98
101
 
99
102
  ## Mastra platform
100
103
 
@@ -102,15 +105,16 @@ For hosted traces, logs, and metrics across projects and deploys, see [Observabi
102
105
 
103
106
  ## Storage
104
107
 
105
- 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).
106
-
107
- 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.
108
+ Not all storage backends support every signal. Traces work with most backends, but metrics and logs require an OLAP-capable store like DuckDB (development) or ClickHouse (production). For setup guidance, see [Storage](https://mastra.ai/docs/observability/storage).
108
109
 
109
110
  ## Next steps
110
111
 
111
112
  - [Tracing](https://mastra.ai/docs/observability/tracing/overview)
112
113
  - [Logging](https://mastra.ai/docs/observability/logging)
113
114
  - [Metrics](https://mastra.ai/docs/observability/metrics/overview)
115
+ - [Configuration](https://mastra.ai/docs/observability/config)
116
+ - [Storage](https://mastra.ai/docs/observability/storage)
117
+ - [Integrations overview](https://mastra.ai/docs/observability/integrations/overview)
114
118
  - [Mastra Studio](https://mastra.ai/docs/studio/observability)
115
119
  - [Automatic metrics reference](https://mastra.ai/reference/observability/metrics/automatic-metrics)
116
120
  - [Mastra platform observability](https://mastra.ai/docs/mastra-platform/observability)
@@ -0,0 +1,79 @@
1
+ # Storage
2
+
3
+ Storage determines which observability signals persist, which queries are available, and whether metrics aggregation works. Use a dedicated observability store instead of your primary application store.
4
+
5
+ ## When to use storage
6
+
7
+ - Keep traces, logs, and metrics available in Mastra Studio during development.
8
+ - Enable metrics with an OLAP-capable observability store.
9
+ - Route the observability domain to a dedicated production backend.
10
+
11
+ ## Quickstart
12
+
13
+ The following example demonstrates the recommended local testing setup: route observability data to DuckDB while keeping the rest of your application on LibSQL.
14
+
15
+ ```ts
16
+ import { Mastra } from '@mastra/core/mastra'
17
+ import { LibSQLStore } from '@mastra/libsql'
18
+ import { DuckDBStore } from '@mastra/duckdb'
19
+ import { MastraCompositeStore } from '@mastra/core/storage'
20
+ import { Observability, MastraStorageExporter } from '@mastra/observability'
21
+
22
+ export const mastra = new Mastra({
23
+ storage: new MastraCompositeStore({
24
+ id: 'composite-storage',
25
+ default: new LibSQLStore({
26
+ id: 'mastra-storage',
27
+ url: 'file:./mastra.db',
28
+ }),
29
+ domains: {
30
+ observability: await new DuckDBStore().getStore('observability'),
31
+ },
32
+ }),
33
+ observability: new Observability({
34
+ configs: {
35
+ default: {
36
+ serviceName: 'mastra',
37
+ exporters: [new MastraStorageExporter()],
38
+ },
39
+ },
40
+ }),
41
+ })
42
+ ```
43
+
44
+ ## Signal support
45
+
46
+ Mastra storage-backed observability currently depends on an OLAP-capable backend for full signal support:
47
+
48
+ - DuckDB: Recommended for local testing and development.
49
+ - ClickHouse: Recommended for production observability.
50
+ - Mastra platform: Use `MastraPlatformExporter` if you want hosted observability without managing the backend yourself.
51
+
52
+ Primary application stores such as LibSQL or PostgreSQL should not be used as the observability store. Route the `observability` domain separately with composite storage when you use `MastraStorageExporter`.
53
+
54
+ ## Local development
55
+
56
+ For local development, the recommended setup is:
57
+
58
+ - `LibSQLStore` for primary application storage
59
+ - `DuckDBStore` for the `observability` domain
60
+ - `MastraStorageExporter` for local Studio access
61
+
62
+ This setup is for local testing and development. It gives you persisted traces, logs, and metrics without introducing external infrastructure.
63
+
64
+ ## Production deployment
65
+
66
+ Observability traffic is usually more write-heavy than the rest of the application. In production:
67
+
68
+ - Use `MastraStorageExporter` with ClickHouse for the `observability` domain when you keep observability in your own storage.
69
+ - Use `MastraPlatformExporter` if you want hosted Mastra platform observability instead of managing the backend yourself.
70
+ - Do not route observability to your primary application store.
71
+
72
+ For backend compatibility details and exporter batching behavior, see [Mastra Storage exporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage).
73
+
74
+ ## Next steps
75
+
76
+ - [Configuration](https://mastra.ai/docs/observability/config)
77
+ - [Logging](https://mastra.ai/docs/observability/logging)
78
+ - [Metrics overview](https://mastra.ai/docs/observability/metrics/overview)
79
+ - [Mastra Storage exporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)