@mastra/core 1.18.1-alpha.0 → 1.19.0-alpha.2

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 (225) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/agent/agent-legacy.d.ts +3 -1
  3. package/dist/agent/agent-legacy.d.ts.map +1 -1
  4. package/dist/agent/agent.d.ts +3 -1
  5. package/dist/agent/agent.d.ts.map +1 -1
  6. package/dist/agent/index.cjs +8 -8
  7. package/dist/agent/index.js +1 -1
  8. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  9. package/dist/{chunk-AV4YSAZL.cjs → chunk-2OYWVA6F.cjs} +17 -2
  10. package/dist/chunk-2OYWVA6F.cjs.map +1 -0
  11. package/dist/{chunk-45LU555A.cjs → chunk-2RTFET56.cjs} +7 -7
  12. package/dist/{chunk-45LU555A.cjs.map → chunk-2RTFET56.cjs.map} +1 -1
  13. package/dist/{chunk-LKZQG2ZZ.cjs → chunk-4TUILCMR.cjs} +7 -6
  14. package/dist/chunk-4TUILCMR.cjs.map +1 -0
  15. package/dist/{chunk-NMDKJUHA.cjs → chunk-5OBBDZBA.cjs} +185 -185
  16. package/dist/{chunk-NMDKJUHA.cjs.map → chunk-5OBBDZBA.cjs.map} +1 -1
  17. package/dist/{chunk-OF7ELKXY.js → chunk-6TEEIOHA.js} +4 -4
  18. package/dist/{chunk-OF7ELKXY.js.map → chunk-6TEEIOHA.js.map} +1 -1
  19. package/dist/{chunk-KG5NOH3Z.js → chunk-6XYHMM2X.js} +8 -8
  20. package/dist/{chunk-KG5NOH3Z.js.map → chunk-6XYHMM2X.js.map} +1 -1
  21. package/dist/{chunk-IVXAQT6H.js → chunk-BS5UESNT.js} +93 -42
  22. package/dist/chunk-BS5UESNT.js.map +1 -0
  23. package/dist/{chunk-NRIT3KHS.js → chunk-CSIKD56W.js} +3 -3
  24. package/dist/{chunk-NRIT3KHS.js.map → chunk-CSIKD56W.js.map} +1 -1
  25. package/dist/{chunk-KEYCLRBI.js → chunk-D5EXC3XM.js} +4 -4
  26. package/dist/{chunk-KEYCLRBI.js.map → chunk-D5EXC3XM.js.map} +1 -1
  27. package/dist/{chunk-XQRTJIC7.cjs → chunk-E2SMTTP6.cjs} +45 -16
  28. package/dist/chunk-E2SMTTP6.cjs.map +1 -0
  29. package/dist/{chunk-RVBOSWN5.cjs → chunk-E3JUOJME.cjs} +5 -5
  30. package/dist/{chunk-RVBOSWN5.cjs.map → chunk-E3JUOJME.cjs.map} +1 -1
  31. package/dist/{chunk-FA4PTEBK.js → chunk-EWPUWV33.js} +18 -3
  32. package/dist/chunk-EWPUWV33.js.map +1 -0
  33. package/dist/{chunk-BWRB3RPC.js → chunk-F4PVOQKD.js} +3 -3
  34. package/dist/{chunk-BWRB3RPC.js.map → chunk-F4PVOQKD.js.map} +1 -1
  35. package/dist/{chunk-TJNYXDI7.cjs → chunk-GFQPMPSV.cjs} +7 -113
  36. package/dist/chunk-GFQPMPSV.cjs.map +1 -0
  37. package/dist/{chunk-V2NQOABM.cjs → chunk-GNA52EF4.cjs} +9 -9
  38. package/dist/{chunk-V2NQOABM.cjs.map → chunk-GNA52EF4.cjs.map} +1 -1
  39. package/dist/{chunk-GALW5K2E.js → chunk-IOHKSHT4.js} +3 -3
  40. package/dist/{chunk-GALW5K2E.js.map → chunk-IOHKSHT4.js.map} +1 -1
  41. package/dist/{chunk-Z7DO2WCR.cjs → chunk-IQV2SVCE.cjs} +52 -52
  42. package/dist/{chunk-Z7DO2WCR.cjs.map → chunk-IQV2SVCE.cjs.map} +1 -1
  43. package/dist/{chunk-GXXNF6NF.cjs → chunk-L2FL7HMV.cjs} +35 -30
  44. package/dist/chunk-L2FL7HMV.cjs.map +1 -0
  45. package/dist/{chunk-HZI7AYCD.js → chunk-M62LMDHE.js} +8 -7
  46. package/dist/chunk-M62LMDHE.js.map +1 -0
  47. package/dist/{chunk-TPE5VTVF.cjs → chunk-MN7WNZE6.cjs} +6 -6
  48. package/dist/{chunk-TPE5VTVF.cjs.map → chunk-MN7WNZE6.cjs.map} +1 -1
  49. package/dist/{chunk-7W6PDCOH.cjs → chunk-NWOPWLJ3.cjs} +83 -82
  50. package/dist/chunk-NWOPWLJ3.cjs.map +1 -0
  51. package/dist/{chunk-CJ4RMDJJ.cjs → chunk-O542TXPV.cjs} +145 -94
  52. package/dist/chunk-O542TXPV.cjs.map +1 -0
  53. package/dist/{chunk-4FMKWOPC.js → chunk-OZHBY6NY.js} +32 -5
  54. package/dist/chunk-OZHBY6NY.js.map +1 -0
  55. package/dist/{chunk-MJF7NZEF.js → chunk-PPCEPCG7.js} +3 -3
  56. package/dist/{chunk-MJF7NZEF.js.map → chunk-PPCEPCG7.js.map} +1 -1
  57. package/dist/{chunk-CU764D5P.cjs → chunk-QB4YHCVA.cjs} +15 -15
  58. package/dist/{chunk-CU764D5P.cjs.map → chunk-QB4YHCVA.cjs.map} +1 -1
  59. package/dist/{chunk-K7AE4BHR.js → chunk-QIOD3LOP.js} +4 -3
  60. package/dist/chunk-QIOD3LOP.js.map +1 -0
  61. package/dist/{chunk-DTT543MP.cjs → chunk-RD76XK7E.cjs} +3 -3
  62. package/dist/{chunk-DTT543MP.cjs.map → chunk-RD76XK7E.cjs.map} +1 -1
  63. package/dist/{chunk-HRT662B6.js → chunk-SVIEJH5H.js} +13 -8
  64. package/dist/chunk-SVIEJH5H.js.map +1 -0
  65. package/dist/{chunk-KFL6ZGWG.js → chunk-VYZRHQUD.js} +5 -5
  66. package/dist/{chunk-KFL6ZGWG.js.map → chunk-VYZRHQUD.js.map} +1 -1
  67. package/dist/{chunk-H5ZOJOQ2.cjs → chunk-WKAEIA42.cjs} +9 -9
  68. package/dist/{chunk-H5ZOJOQ2.cjs.map → chunk-WKAEIA42.cjs.map} +1 -1
  69. package/dist/{chunk-L3V6LSQF.js → chunk-X5BBF6AG.js} +3 -3
  70. package/dist/{chunk-L3V6LSQF.js.map → chunk-X5BBF6AG.js.map} +1 -1
  71. package/dist/{chunk-WGJL6F3F.js → chunk-Z6I5PBGG.js} +6 -112
  72. package/dist/chunk-Z6I5PBGG.js.map +1 -0
  73. package/dist/datasets/index.cjs +17 -17
  74. package/dist/datasets/index.js +2 -2
  75. package/dist/docs/SKILL.md +8 -18
  76. package/dist/docs/assets/SOURCE_MAP.json +266 -266
  77. package/dist/docs/references/docs-agents-overview.md +4 -4
  78. package/dist/docs/references/docs-agents-processors.md +1 -1
  79. package/dist/docs/references/{docs-observability-datasets-overview.md → docs-evals-datasets-overview.md} +12 -12
  80. package/dist/docs/references/{docs-observability-datasets-running-experiments.md → docs-evals-datasets-running-experiments.md} +9 -9
  81. package/dist/docs/references/docs-evals-overview.md +8 -9
  82. package/dist/docs/references/docs-memory-observational-memory.md +20 -11
  83. package/dist/docs/references/docs-memory-overview.md +4 -4
  84. package/dist/docs/references/docs-memory-semantic-recall.md +28 -19
  85. package/dist/docs/references/docs-memory-storage.md +4 -4
  86. package/dist/docs/references/docs-rag-chunking-and-embedding.md +2 -2
  87. package/dist/docs/references/docs-server-auth-composite-auth.md +1 -7
  88. package/dist/docs/references/docs-server-auth-custom-auth-provider.md +2 -4
  89. package/dist/docs/references/docs-server-auth-jwt.md +1 -1
  90. package/dist/docs/references/docs-server-auth-simple-auth.md +1 -7
  91. package/dist/docs/references/docs-server-custom-adapters.md +3 -1
  92. package/dist/docs/references/docs-server-custom-api-routes.md +1 -1
  93. package/dist/docs/references/docs-server-mastra-client.md +1 -3
  94. package/dist/docs/references/docs-server-mastra-server.md +8 -0
  95. package/dist/docs/references/docs-server-request-context.md +17 -17
  96. package/dist/docs/references/docs-streaming-events.md +1 -90
  97. package/dist/docs/references/docs-studio-auth.md +142 -0
  98. package/dist/docs/references/docs-studio-deployment.md +260 -0
  99. package/dist/docs/references/docs-studio-observability.md +98 -0
  100. package/dist/docs/references/docs-studio-overview.md +127 -0
  101. package/dist/docs/references/docs-workflows-agents-and-tools.md +7 -10
  102. package/dist/docs/references/docs-workflows-control-flow.md +1 -1
  103. package/dist/docs/references/docs-workflows-overview.md +12 -7
  104. package/dist/docs/references/docs-workflows-suspend-and-resume.md +1 -1
  105. package/dist/docs/references/guides-concepts-multi-agent-systems.md +4 -4
  106. package/dist/docs/references/reference-agents-agent.md +1 -1
  107. package/dist/docs/references/reference-configuration.md +4 -4
  108. package/dist/docs/references/reference-memory-observational-memory.md +1 -1
  109. package/dist/docs/references/reference-storage-cloudflare-d1.md +1 -1
  110. package/dist/docs/references/reference-storage-lance.md +1 -1
  111. package/dist/docs/references/reference-storage-upstash.md +1 -1
  112. package/dist/docs/references/reference.md +16 -14
  113. package/dist/evals/index.cjs +5 -5
  114. package/dist/evals/index.js +2 -2
  115. package/dist/evals/scoreTraces/index.cjs +3 -3
  116. package/dist/evals/scoreTraces/index.js +1 -1
  117. package/dist/harness/harness.d.ts.map +1 -1
  118. package/dist/harness/index.cjs +19 -18
  119. package/dist/harness/index.cjs.map +1 -1
  120. package/dist/harness/index.js +9 -8
  121. package/dist/harness/index.js.map +1 -1
  122. package/dist/index.cjs +2 -2
  123. package/dist/index.js +1 -1
  124. package/dist/integration/index.cjs +2 -2
  125. package/dist/integration/index.js +1 -1
  126. package/dist/llm/index.cjs +16 -16
  127. package/dist/llm/index.js +5 -5
  128. package/dist/llm/model/aisdk/v5/model.d.ts +5 -0
  129. package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
  130. package/dist/llm/model/aisdk/v6/model.d.ts +5 -0
  131. package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -1
  132. package/dist/llm/model/provider-types.generated.d.ts +1 -50
  133. package/dist/loop/index.cjs +14 -14
  134. package/dist/loop/index.js +1 -1
  135. package/dist/loop/network/validation.d.ts.map +1 -1
  136. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  137. package/dist/mastra/index.cjs +2 -2
  138. package/dist/mastra/index.js +1 -1
  139. package/dist/memory/index.cjs +14 -14
  140. package/dist/memory/index.js +1 -1
  141. package/dist/models-dev-VAVD7BDV.cjs +12 -0
  142. package/dist/{models-dev-674ULLFE.cjs.map → models-dev-VAVD7BDV.cjs.map} +1 -1
  143. package/dist/models-dev-VFIUOVG4.js +3 -0
  144. package/dist/{models-dev-AVV7SNWL.js.map → models-dev-VFIUOVG4.js.map} +1 -1
  145. package/dist/netlify-KL3UR26O.cjs +12 -0
  146. package/dist/{netlify-QP3MZ4FK.cjs.map → netlify-KL3UR26O.cjs.map} +1 -1
  147. package/dist/netlify-Q3SJTV4U.js +3 -0
  148. package/dist/{netlify-KWEJPG27.js.map → netlify-Q3SJTV4U.js.map} +1 -1
  149. package/dist/processor-provider/index.cjs +10 -10
  150. package/dist/processor-provider/index.js +1 -1
  151. package/dist/processors/index.cjs +44 -44
  152. package/dist/processors/index.js +1 -1
  153. package/dist/provider-registry-COX4XKGI.js +3 -0
  154. package/dist/{provider-registry-L3LFTZUA.js.map → provider-registry-COX4XKGI.js.map} +1 -1
  155. package/dist/provider-registry-IAU4XHVY.cjs +40 -0
  156. package/dist/{provider-registry-KZN4FOFE.cjs.map → provider-registry-IAU4XHVY.cjs.map} +1 -1
  157. package/dist/provider-registry.json +2 -108
  158. package/dist/relevance/index.cjs +3 -3
  159. package/dist/relevance/index.js +1 -1
  160. package/dist/storage/index.cjs +74 -74
  161. package/dist/storage/index.js +1 -1
  162. package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
  163. package/dist/stream/index.cjs +8 -8
  164. package/dist/stream/index.js +1 -1
  165. package/dist/test-utils/llm-mock.cjs +4 -4
  166. package/dist/test-utils/llm-mock.js +1 -1
  167. package/dist/tool-loop-agent/index.cjs +4 -4
  168. package/dist/tool-loop-agent/index.js +1 -1
  169. package/dist/tools/index.cjs +8 -8
  170. package/dist/tools/index.js +1 -1
  171. package/dist/tools/is-vercel-tool.cjs +2 -2
  172. package/dist/tools/is-vercel-tool.js +1 -1
  173. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  174. package/dist/tools/validation.d.ts.map +1 -1
  175. package/dist/utils.cjs +31 -23
  176. package/dist/utils.d.ts +10 -0
  177. package/dist/utils.d.ts.map +1 -1
  178. package/dist/utils.js +1 -1
  179. package/dist/vector/index.cjs +7 -7
  180. package/dist/vector/index.js +1 -1
  181. package/dist/workflows/evented/index.cjs +10 -10
  182. package/dist/workflows/evented/index.js +1 -1
  183. package/dist/workflows/index.cjs +24 -24
  184. package/dist/workflows/index.js +1 -1
  185. package/dist/workflows/workflow.d.ts.map +1 -1
  186. package/dist/workspace/index.cjs +68 -68
  187. package/dist/workspace/index.js +1 -1
  188. package/dist/workspace/workspace.d.ts +1 -0
  189. package/dist/workspace/workspace.d.ts.map +1 -1
  190. package/package.json +5 -5
  191. package/src/llm/model/provider-types.generated.d.ts +1 -50
  192. package/dist/chunk-4FMKWOPC.js.map +0 -1
  193. package/dist/chunk-7W6PDCOH.cjs.map +0 -1
  194. package/dist/chunk-AV4YSAZL.cjs.map +0 -1
  195. package/dist/chunk-CJ4RMDJJ.cjs.map +0 -1
  196. package/dist/chunk-FA4PTEBK.js.map +0 -1
  197. package/dist/chunk-GXXNF6NF.cjs.map +0 -1
  198. package/dist/chunk-HRT662B6.js.map +0 -1
  199. package/dist/chunk-HZI7AYCD.js.map +0 -1
  200. package/dist/chunk-IVXAQT6H.js.map +0 -1
  201. package/dist/chunk-K7AE4BHR.js.map +0 -1
  202. package/dist/chunk-LKZQG2ZZ.cjs.map +0 -1
  203. package/dist/chunk-TJNYXDI7.cjs.map +0 -1
  204. package/dist/chunk-WGJL6F3F.js.map +0 -1
  205. package/dist/chunk-XQRTJIC7.cjs.map +0 -1
  206. package/dist/docs/references/docs-observability-logging.md +0 -99
  207. package/dist/docs/references/docs-observability-overview.md +0 -70
  208. package/dist/docs/references/docs-observability-tracing-bridges-otel.md +0 -209
  209. package/dist/docs/references/docs-observability-tracing-exporters-arize.md +0 -272
  210. package/dist/docs/references/docs-observability-tracing-exporters-braintrust.md +0 -126
  211. package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +0 -127
  212. package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +0 -317
  213. package/dist/docs/references/docs-observability-tracing-exporters-default.md +0 -209
  214. package/dist/docs/references/docs-observability-tracing-exporters-laminar.md +0 -100
  215. package/dist/docs/references/docs-observability-tracing-exporters-langfuse.md +0 -213
  216. package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +0 -198
  217. package/dist/docs/references/docs-observability-tracing-exporters-otel.md +0 -476
  218. package/dist/docs/references/docs-observability-tracing-exporters-posthog.md +0 -148
  219. package/dist/docs/references/docs-observability-tracing-overview.md +0 -1112
  220. package/dist/models-dev-674ULLFE.cjs +0 -12
  221. package/dist/models-dev-AVV7SNWL.js +0 -3
  222. package/dist/netlify-KWEJPG27.js +0 -3
  223. package/dist/netlify-QP3MZ4FK.cjs +0 -12
  224. package/dist/provider-registry-KZN4FOFE.cjs +0 -40
  225. package/dist/provider-registry-L3LFTZUA.js +0 -3
@@ -1,317 +0,0 @@
1
- # Datadog exporter
2
-
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
-
5
- ## Installation
6
-
7
- **npm**:
8
-
9
- ```bash
10
- npm install @mastra/datadog@latest
11
- ```
12
-
13
- **pnpm**:
14
-
15
- ```bash
16
- pnpm add @mastra/datadog@latest
17
- ```
18
-
19
- **Yarn**:
20
-
21
- ```bash
22
- yarn add @mastra/datadog@latest
23
- ```
24
-
25
- **Bun**:
26
-
27
- ```bash
28
- bun add @mastra/datadog@latest
29
- ```
30
-
31
- ## Configuration
32
-
33
- ### Prerequisites
34
-
35
- 1. **Datadog Account**: Sign up at [datadoghq.com](https://datadoghq.com/) with LLM Observability enabled
36
- 2. **API Key**: Get your API key from Datadog Organization Settings → API Keys
37
- 3. **Environment Variables**: Set your credentials
38
-
39
- ```bash
40
- DD_API_KEY=your-datadog-api-key
41
- DD_LLMOBS_ML_APP=my-llm-app
42
- DD_SITE=datadoghq.com # Optional: defaults to datadoghq.com
43
- DD_ENV=production # Optional: environment name
44
- ```
45
-
46
- ### Zero-Config Setup
47
-
48
- With environment variables set, use the exporter with no configuration:
49
-
50
- ```typescript
51
- import { Mastra } from '@mastra/core'
52
- import { Observability } from '@mastra/observability'
53
- import { DatadogExporter } from '@mastra/datadog'
54
-
55
- export const mastra = new Mastra({
56
- observability: new Observability({
57
- configs: {
58
- datadog: {
59
- serviceName: 'my-service',
60
- exporters: [new DatadogExporter()],
61
- },
62
- },
63
- }),
64
- })
65
- ```
66
-
67
- ### Explicit Configuration
68
-
69
- You can also pass credentials directly (takes precedence over environment variables):
70
-
71
- ```typescript
72
- import { Mastra } from '@mastra/core'
73
- import { Observability } from '@mastra/observability'
74
- import { DatadogExporter } from '@mastra/datadog'
75
-
76
- export const mastra = new Mastra({
77
- observability: new Observability({
78
- configs: {
79
- datadog: {
80
- serviceName: 'my-service',
81
- exporters: [
82
- new DatadogExporter({
83
- mlApp: process.env.DD_LLMOBS_ML_APP!,
84
- apiKey: process.env.DD_API_KEY!,
85
- }),
86
- ],
87
- },
88
- },
89
- }),
90
- })
91
- ```
92
-
93
- ## Configuration options
94
-
95
- ### Complete Configuration
96
-
97
- ```typescript
98
- new DatadogExporter({
99
- // Required settings
100
- mlApp: process.env.DD_LLMOBS_ML_APP!, // Groups traces under this ML app name
101
- apiKey: process.env.DD_API_KEY!, // Required for agentless mode (default)
102
-
103
- // Optional settings
104
- site: 'datadoghq.com', // Datadog site (datadoghq.eu, us3.datadoghq.com, etc.)
105
- service: 'my-service', // Service name (defaults to mlApp)
106
- env: 'production', // Environment name
107
- agentless: true, // true = direct HTTPS, false = local Datadog Agent
108
-
109
- // Advanced settings
110
- integrationsEnabled: false, // Enable dd-trace auto-instrumentation
111
-
112
- // Diagnostic logging
113
- logLevel: 'info', // debug | info | warn | error
114
- })
115
- ```
116
-
117
- ### With Local Datadog Agent
118
-
119
- If you have a Datadog Agent running locally, you can route traces through it instead of direct HTTPS:
120
-
121
- ```typescript
122
- new DatadogExporter({
123
- mlApp: process.env.DD_LLMOBS_ML_APP!,
124
- agentless: false, // Use local Datadog Agent
125
- env: 'production',
126
- })
127
- ```
128
-
129
- Note: When using agent mode, the API key is read from the local agent's configuration.
130
-
131
- ## Span type mapping
132
-
133
- Mastra span types are automatically mapped to Datadog LLMObs span kinds:
134
-
135
- | Mastra SpanType | Datadog Kind |
136
- | -------------------- | ------------ |
137
- | `AGENT_RUN` | `agent` |
138
- | `MODEL_GENERATION` | `workflow` |
139
- | `MODEL_STEP` | `llm` |
140
- | `TOOL_CALL` | `tool` |
141
- | `MCP_TOOL_CALL` | `tool` |
142
- | `WORKFLOW_RUN` | `workflow` |
143
- | Other workflow types | `task` |
144
- | `GENERIC` | `task` |
145
-
146
- Other/future Mastra span types will default to 'task' when mapped unless specified.
147
-
148
- ## Application Performance Monitoring
149
-
150
- The sections above cover Mastra's [LLM Observability](https://docs.datadoghq.com/llm_observability/) integration. To trace your Mastra HTTP server routes (request latency, error tracking, service maps), use `dd-trace` directly for Datadog Application Performance Monitoring (APM).
151
-
152
- ### Prerequisites
153
-
154
- 1. **Datadog Agent**: Install a [Datadog Agent](https://docs.datadoghq.com/agent/) on the same host or accessible via network. The agent receives traces from `dd-trace` on `localhost:8126` and forwards them to Datadog. Follow the [agent installation guide](https://docs.datadoghq.com/agent/) to set it up.
155
-
156
- 2. **dd-trace package**: Install the tracing library in your project:
157
-
158
- **npm**:
159
-
160
- ```bash
161
- npm install dd-trace
162
- ```
163
-
164
- **pnpm**:
165
-
166
- ```bash
167
- pnpm add dd-trace
168
- ```
169
-
170
- **Yarn**:
171
-
172
- ```bash
173
- yarn add dd-trace
174
- ```
175
-
176
- **Bun**:
177
-
178
- ```bash
179
- bun add dd-trace
180
- ```
181
-
182
- > **Note:** APM traces always route through the Datadog Agent. This is different from LLM Observability, which supports agentless mode (direct HTTPS to Datadog).
183
-
184
- ### APM only
185
-
186
- Import and initialize `dd-trace` at the top of your entry file, before any other imports:
187
-
188
- ```typescript
189
- import tracer from 'dd-trace'
190
-
191
- tracer.init({
192
- service: process.env.DD_SERVICE || 'my-mastra-app',
193
- env: process.env.DD_ENV || 'production',
194
- version: process.env.DD_VERSION,
195
- })
196
-
197
- import { Mastra } from '@mastra/core'
198
-
199
- export const mastra = new Mastra({
200
- bundler: {
201
- externals: [
202
- 'dd-trace',
203
- '@datadog/native-metrics',
204
- '@datadog/native-appsec',
205
- '@datadog/native-iast-taint-tracking',
206
- '@datadog/pprof',
207
- ],
208
- },
209
- })
210
- ```
211
-
212
- Set the tracer metadata environment variables:
213
-
214
- ```bash
215
- DD_SERVICE=my-mastra-app
216
- DD_ENV=production
217
- DD_VERSION=1.0.0
218
- ```
219
-
220
- `dd-trace` auto-instruments popular HTTP frameworks, including those supported by Mastra's [server adapters](https://mastra.ai/docs/server/server-adapters). Inbound requests, outbound HTTP calls, and database queries appear as APM traces in Datadog.
221
-
222
- ### APM and LLM Observability
223
-
224
- Import and initialize `dd-trace` before creating the Mastra instance. The `DatadogExporter` detects the existing tracer and skips re-initialization, adding LLM Observability on top of your APM setup:
225
-
226
- ```typescript
227
- import tracer from 'dd-trace'
228
-
229
- tracer.init({
230
- service: process.env.DD_SERVICE || 'my-mastra-app',
231
- env: process.env.DD_ENV || 'production',
232
- version: process.env.DD_VERSION,
233
- })
234
-
235
- import { Mastra } from '@mastra/core'
236
- import { Observability } from '@mastra/observability'
237
- import { DatadogExporter } from '@mastra/datadog'
238
-
239
- export const mastra = new Mastra({
240
- observability: new Observability({
241
- configs: {
242
- datadog: {
243
- serviceName: 'my-mastra-app',
244
- exporters: [
245
- new DatadogExporter({
246
- mlApp: process.env.DD_LLMOBS_ML_APP!,
247
- apiKey: process.env.DD_API_KEY!,
248
- }),
249
- ],
250
- },
251
- },
252
- }),
253
- bundler: {
254
- externals: [
255
- 'dd-trace',
256
- '@datadog/native-metrics',
257
- '@datadog/native-appsec',
258
- '@datadog/native-iast-taint-tracking',
259
- '@datadog/pprof',
260
- ],
261
- },
262
- })
263
- ```
264
-
265
- ```bash
266
- DD_SERVICE=my-mastra-app
267
- DD_ENV=production
268
- DD_VERSION=1.0.0
269
- DD_API_KEY=your-datadog-api-key
270
- DD_LLMOBS_ML_APP=my-llm-app
271
- ```
272
-
273
- Server routes appear as APM traces and LLM calls appear as LLM Observability spans, all under the same service in Datadog.
274
-
275
- > **Note:** Import and initialize `dd-trace` before all other modules. This allows its auto-instrumentation to patch HTTP, database, and framework libraries at load time.
276
-
277
- ## Troubleshooting
278
-
279
- ### Native module ABI mismatch
280
-
281
- If you see errors like:
282
-
283
- ```text
284
- Error: No native build was found for runtime=node abi=137 platform=linuxglibc arch=x64
285
- ```
286
-
287
- This indicates a Node.js version compatibility issue with `dd-trace`'s native modules. These native modules are **optional** and provide performance monitoring features.
288
-
289
- **Solutions:**
290
-
291
- 1. **Use Node.js 22.x**: Native modules have the best compatibility with Node.js 22.x.
292
-
293
- 2. **Ignore native module warnings**: The native modules (`@datadog/native-metrics`, `@datadog/native-appsec`, etc.) are optional. If they fail to load, core tracing functionality still works.
294
-
295
- ### Bundler externals configuration
296
-
297
- When using bundlers like esbuild, webpack, or the Mastra CLI bundler, you may need to mark `dd-trace` and its dependencies as external:
298
-
299
- ```typescript
300
- export const mastra = new Mastra({
301
- bundler: {
302
- externals: [
303
- 'dd-trace',
304
- '@datadog/native-metrics',
305
- '@datadog/native-appsec',
306
- '@datadog/native-iast-taint-tracking',
307
- '@datadog/pprof',
308
- ],
309
- },
310
- })
311
- ```
312
-
313
- ## Related
314
-
315
- - [Tracing overview](https://mastra.ai/docs/observability/tracing/overview)
316
- - [Datadog LLM Observability documentation](https://docs.datadoghq.com/llm_observability/)
317
- - [Datadog APM documentation](https://docs.datadoghq.com/tracing/)
@@ -1,209 +0,0 @@
1
- # Default exporter
2
-
3
- The `DefaultExporter` persists traces to your configured storage backend, making them accessible through Studio. It's automatically enabled when using the default observability configuration and requires no external services.
4
-
5
- > **Production Observability:** Observability data can quickly overwhelm general-purpose databases in production. For high-traffic applications, we recommend using **ClickHouse** for the observability storage domain via [composite storage](https://mastra.ai/reference/storage/composite). See [Production Recommendations](#production-recommendations) for details.
6
-
7
- ## Configuration
8
-
9
- ### Prerequisites
10
-
11
- 1. **Storage Backend**: Configure a storage provider (libSQL, PostgreSQL, etc.)
12
- 2. **Studio**: Install for viewing traces locally
13
-
14
- ### Basic Setup
15
-
16
- ```typescript
17
- import { Mastra } from '@mastra/core'
18
- import { Observability, DefaultExporter } from '@mastra/observability'
19
- import { LibSQLStore } from '@mastra/libsql'
20
-
21
- export const mastra = new Mastra({
22
- storage: new LibSQLStore({
23
- id: 'mastra-storage',
24
- url: 'file:./mastra.db', // Required for trace persistence
25
- }),
26
- observability: new Observability({
27
- configs: {
28
- local: {
29
- serviceName: 'my-service',
30
- exporters: [new DefaultExporter()],
31
- },
32
- },
33
- }),
34
- })
35
- ```
36
-
37
- ### Recommended Configuration
38
-
39
- Include DefaultExporter in your observability configuration:
40
-
41
- ```typescript
42
- import { Mastra } from '@mastra/core'
43
- import {
44
- Observability,
45
- DefaultExporter,
46
- CloudExporter,
47
- SensitiveDataFilter,
48
- } from '@mastra/observability'
49
- import { LibSQLStore } from '@mastra/libsql'
50
-
51
- export const mastra = new Mastra({
52
- storage: new LibSQLStore({
53
- id: 'mastra-storage',
54
- url: 'file:./mastra.db',
55
- }),
56
- observability: new Observability({
57
- configs: {
58
- default: {
59
- serviceName: 'mastra',
60
- exporters: [
61
- new DefaultExporter(), // Persists traces to storage for Mastra Studio
62
- new CloudExporter(), // Sends traces to Mastra Cloud (requires MASTRA_CLOUD_ACCESS_TOKEN)
63
- ],
64
- spanOutputProcessors: [new SensitiveDataFilter()],
65
- },
66
- },
67
- }),
68
- })
69
- ```
70
-
71
- ## Viewing traces
72
-
73
- ### Studio
74
-
75
- Access your traces through Studio:
76
-
77
- 1. Start Studio
78
- 2. Navigate to Observability
79
- 3. Filter and search your local traces
80
- 4. Inspect detailed span information
81
-
82
- ## Tracing strategies
83
-
84
- DefaultExporter automatically selects the optimal tracing strategy based on your storage provider. You can also override this selection if needed.
85
-
86
- ### Available Strategies
87
-
88
- | Strategy | Description | Use Case |
89
- | ---------------------- | --------------------------------------------------------- | ----------------------------------- |
90
- | **realtime** | Process each event immediately | Development, debugging, low traffic |
91
- | **batch-with-updates** | Buffer events and batch write with full lifecycle support | Low volume Production |
92
- | **insert-only** | Only process completed spans, ignore updates | High volume Production |
93
-
94
- ### Strategy Configuration
95
-
96
- ```typescript
97
- new DefaultExporter({
98
- strategy: 'auto', // Default - let storage provider decide
99
- // or explicitly set:
100
- // strategy: 'realtime' | 'batch-with-updates' | 'insert-only'
101
-
102
- // Batching configuration (applies to both batch-with-updates and insert-only)
103
- maxBatchSize: 1000, // Max spans per batch
104
- maxBatchWaitMs: 5000, // Max wait before flushing
105
- maxBufferSize: 10000, // Max spans to buffer
106
- })
107
- ```
108
-
109
- ## Storage provider support
110
-
111
- Different storage providers support different tracing strategies. Some providers support observability for production workloads, while others are intended primarily for local development.
112
-
113
- If you set the strategy to `'auto'`, the `DefaultExporter` automatically selects the optimal strategy for the storage provider. If you set the strategy to a mode that the storage provider doesn't support, you will get an error message.
114
-
115
- ### Providers with Observability Support
116
-
117
- | Storage Provider | Preferred Strategy | Supported Strategies | Recommended Use |
118
- | ---------------------------------------------------------------- | ------------------ | ------------------------------- | ------------------------------------- |
119
- | **ClickHouse** (`@mastra/clickhouse`) | insert-only | insert-only | Production (high-volume) |
120
- | **[PostgreSQL](https://mastra.ai/reference/storage/postgresql)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
121
- | **[MSSQL](https://mastra.ai/reference/storage/mssql)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
122
- | **[MongoDB](https://mastra.ai/reference/storage/mongodb)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
123
- | **[libSQL](https://mastra.ai/reference/storage/libsql)** | batch-with-updates | batch-with-updates, insert-only | Default storage, good for development |
124
-
125
- ### Providers without Observability Support
126
-
127
- The following storage providers **don't support** the observability domain. If you're using one of these providers and need observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider:
128
-
129
- - [Convex](https://mastra.ai/reference/storage/convex)
130
- - [DynamoDB](https://mastra.ai/reference/storage/dynamodb)
131
- - [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1)
132
- - [Cloudflare Durable Objects](https://mastra.ai/reference/storage/cloudflare)
133
- - [Upstash](https://mastra.ai/reference/storage/upstash)
134
- - [LanceDB](https://mastra.ai/reference/storage/lance)
135
-
136
- ### Strategy Benefits
137
-
138
- - **realtime**: Immediate visibility, best for debugging
139
- - **batch-with-updates**: 10-100x throughput improvement, full span lifecycle
140
- - **insert-only**: Additional 70% reduction in database operations, perfect for analytics
141
-
142
- ## Production recommendations
143
-
144
- Observability data grows quickly in production environments. A single agent interaction can generate hundreds of spans, and high-traffic applications can produce thousands of traces per day. Most general-purpose databases aren't optimized for this write-heavy, append-only workload.
145
-
146
- ### Recommended: ClickHouse for High-Volume Production
147
-
148
- [ClickHouse](https://mastra.ai/reference/storage/composite) is a columnar database designed for high-volume analytics workloads. It's the recommended choice for production observability because:
149
-
150
- - **Optimized for writes**: Handles millions of inserts per second
151
- - **Efficient compression**: Reduces storage costs for trace data
152
- - **Fast queries**: Columnar storage enables quick trace lookups and aggregations
153
- - **Time-series native**: Built-in support for time-based data retention and partitioning
154
-
155
- ### Using Composite Storage
156
-
157
- If you're using a provider without observability support (like Convex or DynamoDB) or want to optimize performance, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to ClickHouse while keeping other data in your primary database.
158
-
159
- ## Batching behavior
160
-
161
- ### Flush Triggers
162
-
163
- For both batch strategies (`batch-with-updates` and `insert-only`), traces are flushed to storage when any of these conditions are met:
164
-
165
- 1. **Size trigger**: Buffer reaches `maxBatchSize` spans
166
- 2. **Time trigger**: `maxBatchWaitMs` elapsed since first event
167
- 3. **Emergency flush**: Buffer approaches `maxBufferSize` limit
168
- 4. **Shutdown**: Force flush all pending events
169
-
170
- ### Error handling
171
-
172
- The DefaultExporter includes robust error handling for production use:
173
-
174
- - **Retry Logic**: Exponential backoff (500ms, 1s, 2s, 4s)
175
- - **Transient Failures**: Automatic retry with backoff
176
- - **Persistent Failures**: Drop batch after 4 failed attempts
177
- - **Buffer Overflow**: Prevent memory issues during storage outages
178
-
179
- ### Configuration Examples
180
-
181
- ```typescript
182
- // Zero config - recommended for most users
183
- new DefaultExporter()
184
-
185
- // Development override
186
- new DefaultExporter({
187
- strategy: 'realtime', // Immediate visibility for debugging
188
- })
189
-
190
- // High-throughput production
191
- new DefaultExporter({
192
- maxBatchSize: 2000, // Larger batches
193
- maxBatchWaitMs: 10000, // Wait longer to fill batches
194
- maxBufferSize: 50000, // Handle longer outages
195
- })
196
-
197
- // Low-latency production
198
- new DefaultExporter({
199
- maxBatchSize: 100, // Smaller batches
200
- maxBatchWaitMs: 1000, // Flush quickly
201
- })
202
- ```
203
-
204
- ## Related
205
-
206
- - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
207
- - [CloudExporter](https://mastra.ai/docs/observability/tracing/exporters/cloud)
208
- - [Composite Storage](https://mastra.ai/reference/storage/composite) - Combine multiple storage providers
209
- - [Storage Configuration](https://mastra.ai/docs/memory/storage)
@@ -1,100 +0,0 @@
1
- # Laminar exporter
2
-
3
- [Laminar](https://laminar.sh/) is an open-source platform for engineering LLM products. The Laminar exporter sends your Mastra traces to Laminar via OTLP/HTTP (protobuf), with Laminar-native span attributes for correct rendering (paths, inputs/outputs, tags, metadata).
4
-
5
- ## Installation
6
-
7
- **npm**:
8
-
9
- ```bash
10
- npm install @mastra/laminar@beta
11
- ```
12
-
13
- **pnpm**:
14
-
15
- ```bash
16
- pnpm add @mastra/laminar@beta
17
- ```
18
-
19
- **Yarn**:
20
-
21
- ```bash
22
- yarn add @mastra/laminar@beta
23
- ```
24
-
25
- **Bun**:
26
-
27
- ```bash
28
- bun add @mastra/laminar@beta
29
- ```
30
-
31
- ## Configuration
32
-
33
- ### Prerequisites
34
-
35
- 1. **Laminar Project**: Create/select a project in Laminar
36
- 2. **Project API Key**: Copy from Laminar Project Settings
37
- 3. **Environment Variables**: Set your credentials
38
-
39
- ```bash
40
- # Required
41
- LMNR_PROJECT_API_KEY=lmnr_...
42
-
43
- # Optional
44
- LMNR_BASE_URL=https://api.lmnr.ai
45
- LAMINAR_ENDPOINT=https://api.lmnr.ai/v1/traces
46
- ```
47
-
48
- ### Zero-Config Setup
49
-
50
- With environment variables set, use the exporter with no configuration:
51
-
52
- ```typescript
53
- import { Mastra } from '@mastra/core'
54
- import { Observability } from '@mastra/observability'
55
- import { LaminarExporter } from '@mastra/laminar'
56
-
57
- export const mastra = new Mastra({
58
- observability: new Observability({
59
- configs: {
60
- laminar: {
61
- serviceName: 'my-service',
62
- exporters: [new LaminarExporter()],
63
- },
64
- },
65
- }),
66
- })
67
- ```
68
-
69
- ### Explicit Configuration
70
-
71
- You can also pass credentials directly (takes precedence over environment variables):
72
-
73
- ```typescript
74
- import { Mastra } from '@mastra/core'
75
- import { Observability } from '@mastra/observability'
76
- import { LaminarExporter } from '@mastra/laminar'
77
-
78
- export const mastra = new Mastra({
79
- observability: new Observability({
80
- configs: {
81
- laminar: {
82
- serviceName: 'my-service',
83
- exporters: [
84
- new LaminarExporter({
85
- apiKey: process.env.LMNR_PROJECT_API_KEY!,
86
- baseUrl: process.env.LMNR_BASE_URL, // Optional
87
- endpoint: process.env.LAMINAR_ENDPOINT, // Optional
88
- realtime: process.env.NODE_ENV === 'development', // Optional
89
- }),
90
- ],
91
- },
92
- },
93
- }),
94
- })
95
- ```
96
-
97
- ## Related
98
-
99
- - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
100
- - [Laminar Documentation](https://docs.laminar.sh)