@mastra/core 1.18.0 → 1.18.1-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 (211) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/agent/agent.d.ts.map +1 -1
  3. package/dist/agent/index.cjs +8 -8
  4. package/dist/agent/index.js +1 -1
  5. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  6. package/dist/{chunk-KLVNQDUR.cjs → chunk-2W7R236U.cjs} +3 -3
  7. package/dist/chunk-2W7R236U.cjs.map +1 -0
  8. package/dist/{chunk-V2NQOABM.cjs → chunk-5ANYSU2W.cjs} +9 -9
  9. package/dist/{chunk-V2NQOABM.cjs.map → chunk-5ANYSU2W.cjs.map} +1 -1
  10. package/dist/{chunk-KOTSKPTF.cjs → chunk-6R5PT6ZP.cjs} +5 -5
  11. package/dist/{chunk-KOTSKPTF.cjs.map → chunk-6R5PT6ZP.cjs.map} +1 -1
  12. package/dist/{chunk-LKZQG2ZZ.cjs → chunk-6VRSFFQ4.cjs} +7 -6
  13. package/dist/chunk-6VRSFFQ4.cjs.map +1 -0
  14. package/dist/{chunk-2M3HWTRI.js → chunk-7IE4K74P.js} +4 -4
  15. package/dist/{chunk-2M3HWTRI.js.map → chunk-7IE4K74P.js.map} +1 -1
  16. package/dist/{chunk-I4ZSA3XJ.js → chunk-7V3UNILV.js} +4 -4
  17. package/dist/{chunk-I4ZSA3XJ.js.map → chunk-7V3UNILV.js.map} +1 -1
  18. package/dist/{chunk-ZRLAR66M.js → chunk-AJZQPWAV.js} +59 -19
  19. package/dist/chunk-AJZQPWAV.js.map +1 -0
  20. package/dist/{chunk-XOBRMYFA.js → chunk-BZ2MSXOF.js} +3 -3
  21. package/dist/chunk-BZ2MSXOF.js.map +1 -0
  22. package/dist/{chunk-HRT662B6.js → chunk-EAJDF6UV.js} +12 -7
  23. package/dist/chunk-EAJDF6UV.js.map +1 -0
  24. package/dist/{chunk-PWFPYJGG.cjs → chunk-EXDBQKH4.cjs} +15 -15
  25. package/dist/{chunk-PWFPYJGG.cjs.map → chunk-EXDBQKH4.cjs.map} +1 -1
  26. package/dist/{chunk-GJ62FP5X.js → chunk-HQCBFWL2.js} +18 -35
  27. package/dist/chunk-HQCBFWL2.js.map +1 -0
  28. package/dist/{chunk-UPBMT3QM.js → chunk-JTJCFEIY.js} +8 -8
  29. package/dist/{chunk-UPBMT3QM.js.map → chunk-JTJCFEIY.js.map} +1 -1
  30. package/dist/{chunk-GJIN53S6.cjs → chunk-L2GYXPJJ.cjs} +9 -9
  31. package/dist/{chunk-GJIN53S6.cjs.map → chunk-L2GYXPJJ.cjs.map} +1 -1
  32. package/dist/{chunk-2H53MD2U.cjs → chunk-LVZKPNQO.cjs} +50 -50
  33. package/dist/{chunk-2H53MD2U.cjs.map → chunk-LVZKPNQO.cjs.map} +1 -1
  34. package/dist/{chunk-MJF7NZEF.js → chunk-OLHODPXN.js} +3 -3
  35. package/dist/{chunk-MJF7NZEF.js.map → chunk-OLHODPXN.js.map} +1 -1
  36. package/dist/{chunk-6Z4GSLLO.js → chunk-OTJAMDX5.js} +3 -3
  37. package/dist/{chunk-6Z4GSLLO.js.map → chunk-OTJAMDX5.js.map} +1 -1
  38. package/dist/{chunk-EKFG6JWW.js → chunk-PB3KXPNE.js} +8 -7
  39. package/dist/chunk-PB3KXPNE.js.map +1 -0
  40. package/dist/{chunk-TVZCMQTV.cjs → chunk-QADPCUBX.cjs} +83 -82
  41. package/dist/chunk-QADPCUBX.cjs.map +1 -0
  42. package/dist/{chunk-RTBZOGTO.js → chunk-QNNFMCSE.js} +3 -3
  43. package/dist/{chunk-RTBZOGTO.js.map → chunk-QNNFMCSE.js.map} +1 -1
  44. package/dist/{chunk-7GLVV6CZ.js → chunk-RF4TETYQ.js} +4 -4
  45. package/dist/{chunk-7GLVV6CZ.js.map → chunk-RF4TETYQ.js.map} +1 -1
  46. package/dist/{chunk-XQN3BKCI.js → chunk-UJX2TJIF.js} +3 -3
  47. package/dist/{chunk-XQN3BKCI.js.map → chunk-UJX2TJIF.js.map} +1 -1
  48. package/dist/{chunk-XQRTJIC7.cjs → chunk-VEP4CV7E.cjs} +32 -3
  49. package/dist/chunk-VEP4CV7E.cjs.map +1 -0
  50. package/dist/{chunk-K7AE4BHR.js → chunk-VMBWVH4B.js} +4 -3
  51. package/dist/chunk-VMBWVH4B.js.map +1 -0
  52. package/dist/{chunk-J47RNLSY.cjs → chunk-WLNT3YJ7.cjs} +95 -55
  53. package/dist/chunk-WLNT3YJ7.cjs.map +1 -0
  54. package/dist/{chunk-L3X22YTN.cjs → chunk-WMF4CWAL.cjs} +185 -185
  55. package/dist/{chunk-L3X22YTN.cjs.map → chunk-WMF4CWAL.cjs.map} +1 -1
  56. package/dist/{chunk-4FMKWOPC.js → chunk-X4Q4KB6C.js} +31 -4
  57. package/dist/chunk-X4Q4KB6C.js.map +1 -0
  58. package/dist/{chunk-RTXCZT3M.cjs → chunk-XDZOEUNU.cjs} +19 -36
  59. package/dist/chunk-XDZOEUNU.cjs.map +1 -0
  60. package/dist/{chunk-GXXNF6NF.cjs → chunk-XNBGNCVV.cjs} +15 -10
  61. package/dist/chunk-XNBGNCVV.cjs.map +1 -0
  62. package/dist/{chunk-ZVGS2O2W.cjs → chunk-YCT2YQDL.cjs} +6 -6
  63. package/dist/{chunk-ZVGS2O2W.cjs.map → chunk-YCT2YQDL.cjs.map} +1 -1
  64. package/dist/{chunk-ZQE2VUYD.cjs → chunk-YMPV2RMB.cjs} +7 -7
  65. package/dist/{chunk-ZQE2VUYD.cjs.map → chunk-YMPV2RMB.cjs.map} +1 -1
  66. package/dist/datasets/index.cjs +17 -17
  67. package/dist/datasets/index.js +2 -2
  68. package/dist/docs/SKILL.md +8 -18
  69. package/dist/docs/assets/SOURCE_MAP.json +254 -254
  70. package/dist/docs/references/docs-agents-overview.md +4 -4
  71. package/dist/docs/references/docs-agents-processors.md +1 -1
  72. package/dist/docs/references/{docs-observability-datasets-overview.md → docs-evals-datasets-overview.md} +12 -12
  73. package/dist/docs/references/{docs-observability-datasets-running-experiments.md → docs-evals-datasets-running-experiments.md} +9 -9
  74. package/dist/docs/references/docs-evals-overview.md +8 -9
  75. package/dist/docs/references/docs-memory-observational-memory.md +20 -11
  76. package/dist/docs/references/docs-memory-overview.md +4 -4
  77. package/dist/docs/references/docs-memory-semantic-recall.md +28 -19
  78. package/dist/docs/references/docs-memory-storage.md +4 -4
  79. package/dist/docs/references/docs-rag-chunking-and-embedding.md +2 -2
  80. package/dist/docs/references/docs-server-auth-composite-auth.md +1 -7
  81. package/dist/docs/references/docs-server-auth-custom-auth-provider.md +2 -4
  82. package/dist/docs/references/docs-server-auth-jwt.md +1 -1
  83. package/dist/docs/references/docs-server-auth-simple-auth.md +1 -7
  84. package/dist/docs/references/docs-server-custom-adapters.md +3 -1
  85. package/dist/docs/references/docs-server-custom-api-routes.md +1 -1
  86. package/dist/docs/references/docs-server-mastra-client.md +1 -3
  87. package/dist/docs/references/docs-server-mastra-server.md +8 -0
  88. package/dist/docs/references/docs-server-request-context.md +17 -17
  89. package/dist/docs/references/docs-streaming-events.md +1 -90
  90. package/dist/docs/references/docs-studio-auth.md +142 -0
  91. package/dist/docs/references/docs-studio-deployment.md +260 -0
  92. package/dist/docs/references/docs-studio-observability.md +98 -0
  93. package/dist/docs/references/docs-studio-overview.md +127 -0
  94. package/dist/docs/references/docs-workflows-agents-and-tools.md +7 -10
  95. package/dist/docs/references/docs-workflows-control-flow.md +1 -1
  96. package/dist/docs/references/docs-workflows-overview.md +12 -7
  97. package/dist/docs/references/docs-workflows-suspend-and-resume.md +1 -1
  98. package/dist/docs/references/guides-concepts-multi-agent-systems.md +4 -4
  99. package/dist/docs/references/reference-agents-agent.md +1 -1
  100. package/dist/docs/references/reference-configuration.md +4 -4
  101. package/dist/docs/references/reference-memory-observational-memory.md +1 -1
  102. package/dist/docs/references/reference-storage-cloudflare-d1.md +1 -1
  103. package/dist/docs/references/reference-storage-lance.md +1 -1
  104. package/dist/docs/references/reference-storage-upstash.md +1 -1
  105. package/dist/docs/references/reference.md +16 -14
  106. package/dist/evals/index.cjs +5 -5
  107. package/dist/evals/index.js +2 -2
  108. package/dist/evals/scoreTraces/index.cjs +3 -3
  109. package/dist/evals/scoreTraces/index.js +1 -1
  110. package/dist/harness/harness.d.ts.map +1 -1
  111. package/dist/harness/index.cjs +13 -12
  112. package/dist/harness/index.cjs.map +1 -1
  113. package/dist/harness/index.js +8 -7
  114. package/dist/harness/index.js.map +1 -1
  115. package/dist/index.cjs +2 -2
  116. package/dist/index.js +1 -1
  117. package/dist/llm/index.cjs +16 -16
  118. package/dist/llm/index.js +5 -5
  119. package/dist/llm/model/aisdk/v5/model.d.ts +5 -0
  120. package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
  121. package/dist/llm/model/aisdk/v6/model.d.ts +5 -0
  122. package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -1
  123. package/dist/llm/model/provider-types.generated.d.ts +5 -13
  124. package/dist/loop/index.cjs +14 -14
  125. package/dist/loop/index.js +1 -1
  126. package/dist/loop/network/validation.d.ts.map +1 -1
  127. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  128. package/dist/mastra/index.cjs +2 -2
  129. package/dist/mastra/index.js +1 -1
  130. package/dist/memory/index.cjs +14 -14
  131. package/dist/memory/index.js +1 -1
  132. package/dist/models-dev-WD6XLSFC.cjs +12 -0
  133. package/dist/{models-dev-5WY37RVC.cjs.map → models-dev-WD6XLSFC.cjs.map} +1 -1
  134. package/dist/models-dev-XG4KIUFT.js +3 -0
  135. package/dist/{models-dev-Y2UFJEOO.js.map → models-dev-XG4KIUFT.js.map} +1 -1
  136. package/dist/netlify-FMBBUFKT.cjs +12 -0
  137. package/dist/{netlify-ADZQ5ZNY.cjs.map → netlify-FMBBUFKT.cjs.map} +1 -1
  138. package/dist/netlify-NDOVF45T.js +3 -0
  139. package/dist/{netlify-I4AUVRO2.js.map → netlify-NDOVF45T.js.map} +1 -1
  140. package/dist/processor-provider/index.cjs +10 -10
  141. package/dist/processor-provider/index.js +1 -1
  142. package/dist/processors/index.cjs +44 -44
  143. package/dist/processors/index.js +1 -1
  144. package/dist/provider-registry-KHXFOGCK.js +3 -0
  145. package/dist/{provider-registry-C7SZ5ZT4.js.map → provider-registry-KHXFOGCK.js.map} +1 -1
  146. package/dist/provider-registry-VUG7E4SG.cjs +40 -0
  147. package/dist/{provider-registry-I5RW3MEE.cjs.map → provider-registry-VUG7E4SG.cjs.map} +1 -1
  148. package/dist/provider-registry.json +14 -31
  149. package/dist/relevance/index.cjs +3 -3
  150. package/dist/relevance/index.js +1 -1
  151. package/dist/storage/index.cjs +74 -74
  152. package/dist/storage/index.js +1 -1
  153. package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
  154. package/dist/stream/index.cjs +8 -8
  155. package/dist/stream/index.js +1 -1
  156. package/dist/test-utils/llm-mock.cjs +4 -4
  157. package/dist/test-utils/llm-mock.js +1 -1
  158. package/dist/tool-loop-agent/index.cjs +4 -4
  159. package/dist/tool-loop-agent/index.js +1 -1
  160. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  161. package/dist/utils.cjs +31 -23
  162. package/dist/utils.d.ts +10 -0
  163. package/dist/utils.d.ts.map +1 -1
  164. package/dist/utils.js +1 -1
  165. package/dist/vector/index.cjs +7 -7
  166. package/dist/vector/index.js +1 -1
  167. package/dist/workflows/evented/index.cjs +10 -10
  168. package/dist/workflows/evented/index.js +1 -1
  169. package/dist/workflows/index.cjs +24 -24
  170. package/dist/workflows/index.js +1 -1
  171. package/dist/workflows/workflow.d.ts.map +1 -1
  172. package/dist/workspace/index.cjs +68 -68
  173. package/dist/workspace/index.js +1 -1
  174. package/dist/workspace/workspace.d.ts +1 -0
  175. package/dist/workspace/workspace.d.ts.map +1 -1
  176. package/package.json +2 -2
  177. package/src/llm/model/provider-types.generated.d.ts +5 -13
  178. package/dist/chunk-4FMKWOPC.js.map +0 -1
  179. package/dist/chunk-EKFG6JWW.js.map +0 -1
  180. package/dist/chunk-GJ62FP5X.js.map +0 -1
  181. package/dist/chunk-GXXNF6NF.cjs.map +0 -1
  182. package/dist/chunk-HRT662B6.js.map +0 -1
  183. package/dist/chunk-J47RNLSY.cjs.map +0 -1
  184. package/dist/chunk-K7AE4BHR.js.map +0 -1
  185. package/dist/chunk-KLVNQDUR.cjs.map +0 -1
  186. package/dist/chunk-LKZQG2ZZ.cjs.map +0 -1
  187. package/dist/chunk-RTXCZT3M.cjs.map +0 -1
  188. package/dist/chunk-TVZCMQTV.cjs.map +0 -1
  189. package/dist/chunk-XOBRMYFA.js.map +0 -1
  190. package/dist/chunk-XQRTJIC7.cjs.map +0 -1
  191. package/dist/chunk-ZRLAR66M.js.map +0 -1
  192. package/dist/docs/references/docs-observability-logging.md +0 -99
  193. package/dist/docs/references/docs-observability-overview.md +0 -70
  194. package/dist/docs/references/docs-observability-tracing-bridges-otel.md +0 -209
  195. package/dist/docs/references/docs-observability-tracing-exporters-arize.md +0 -272
  196. package/dist/docs/references/docs-observability-tracing-exporters-braintrust.md +0 -126
  197. package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +0 -127
  198. package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +0 -317
  199. package/dist/docs/references/docs-observability-tracing-exporters-default.md +0 -209
  200. package/dist/docs/references/docs-observability-tracing-exporters-laminar.md +0 -100
  201. package/dist/docs/references/docs-observability-tracing-exporters-langfuse.md +0 -213
  202. package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +0 -198
  203. package/dist/docs/references/docs-observability-tracing-exporters-otel.md +0 -476
  204. package/dist/docs/references/docs-observability-tracing-exporters-posthog.md +0 -148
  205. package/dist/docs/references/docs-observability-tracing-overview.md +0 -1112
  206. package/dist/models-dev-5WY37RVC.cjs +0 -12
  207. package/dist/models-dev-Y2UFJEOO.js +0 -3
  208. package/dist/netlify-ADZQ5ZNY.cjs +0 -12
  209. package/dist/netlify-I4AUVRO2.js +0 -3
  210. package/dist/provider-registry-C7SZ5ZT4.js +0 -3
  211. package/dist/provider-registry-I5RW3MEE.cjs +0 -40
@@ -1,126 +0,0 @@
1
- # Braintrust exporter
2
-
3
- [Braintrust](https://www.braintrust.dev/) is an evaluation and monitoring platform that helps you measure and improve LLM application quality. The Braintrust exporter sends your traces to Braintrust, enabling systematic evaluation, scoring, and experimentation.
4
-
5
- ## Installation
6
-
7
- **npm**:
8
-
9
- ```bash
10
- npm install @mastra/braintrust@latest
11
- ```
12
-
13
- **pnpm**:
14
-
15
- ```bash
16
- pnpm add @mastra/braintrust@latest
17
- ```
18
-
19
- **Yarn**:
20
-
21
- ```bash
22
- yarn add @mastra/braintrust@latest
23
- ```
24
-
25
- **Bun**:
26
-
27
- ```bash
28
- bun add @mastra/braintrust@latest
29
- ```
30
-
31
- ## Configuration
32
-
33
- ### Prerequisites
34
-
35
- 1. **Braintrust Account**: Sign up at [braintrust.dev](https://www.braintrust.dev/)
36
- 2. **Project**: Create or select a project for your traces
37
- 3. **API Key**: Generate in Braintrust Settings → API Keys
38
- 4. **Environment Variables**: Set your credentials:
39
-
40
- ```bash
41
- BRAINTRUST_API_KEY=sk-xxxxxxxxxxxxxxxx
42
-
43
- # Optional
44
- BRAINTRUST_ENDPOINT=https://api.braintrust.dev # Custom endpoint if needed
45
- ```
46
-
47
- ### Zero-Config Setup
48
-
49
- With environment variables set, use the exporter with no configuration:
50
-
51
- ```typescript
52
- import { Mastra } from '@mastra/core'
53
- import { Observability } from '@mastra/observability'
54
- import { BraintrustExporter } from '@mastra/braintrust'
55
-
56
- export const mastra = new Mastra({
57
- observability: new Observability({
58
- configs: {
59
- braintrust: {
60
- serviceName: 'my-service',
61
- exporters: [new BraintrustExporter()],
62
- },
63
- },
64
- }),
65
- })
66
- ```
67
-
68
- ### Explicit Configuration
69
-
70
- You can also pass credentials directly (takes precedence over environment variables):
71
-
72
- ```typescript
73
- import { Mastra } from '@mastra/core'
74
- import { Observability } from '@mastra/observability'
75
- import { BraintrustExporter } from '@mastra/braintrust'
76
-
77
- export const mastra = new Mastra({
78
- observability: new Observability({
79
- configs: {
80
- braintrust: {
81
- serviceName: 'my-service',
82
- exporters: [
83
- new BraintrustExporter({
84
- apiKey: process.env.BRAINTRUST_API_KEY,
85
- projectName: 'my-project',
86
- }),
87
- ],
88
- },
89
- },
90
- }),
91
- })
92
- ```
93
-
94
- ### Complete Configuration
95
-
96
- ```typescript
97
- new BraintrustExporter({
98
- // Required
99
- apiKey: process.env.BRAINTRUST_API_KEY!,
100
-
101
- // Optional settings
102
- projectName: 'my-project', // Default: 'mastra-tracing'
103
- endpoint: 'https://api.braintrust.dev', // Custom endpoint if needed
104
- logLevel: 'info', // Diagnostic logging: debug | info | warn | error
105
- })
106
- ```
107
-
108
- ## Querying Braintrust with returned `spanId`
109
-
110
- 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.
111
-
112
- ```typescript
113
- const result = await agent.stream('Summarize this ticket')
114
-
115
- console.log('Mastra trace ID:', result.traceId)
116
- console.log('Braintrust root span ID:', result.spanId)
117
-
118
- // Use result.spanId in your Braintrust lookup/query path
119
- ```
120
-
121
- The same applies to `agent.generate()` and workflow run results (`run.start()`, `run.stream()` final state, `run.resume()`).
122
-
123
- ## Related
124
-
125
- - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
126
- - [Braintrust Documentation](https://www.braintrust.dev/docs)
@@ -1,127 +0,0 @@
1
- # Cloud exporter
2
-
3
- The `CloudExporter` sends traces to Mastra Cloud for centralized monitoring and team collaboration. It's automatically enabled when using the default observability configuration with a valid access token.
4
-
5
- ## Configuration
6
-
7
- ### Prerequisites
8
-
9
- 1. **Mastra Cloud Account**: Sign up at [cloud.mastra.ai](https://cloud.mastra.ai)
10
- 2. **Mastra Cloud Project**: Create a project in Mastra Cloud. Traces are scoped per project, so even if you only want observability, you need a project to act as the destination for your traces.
11
- 3. **Access Token**: Generate in your project's sidebar under **Project Settings → Access Tokens**
12
- 4. **Environment Variables**: Set your credentials:
13
-
14
- ```bash
15
- MASTRA_CLOUD_ACCESS_TOKEN=mst_xxxxxxxxxxxxxxxx
16
- ```
17
-
18
- ### Basic Setup
19
-
20
- ```typescript
21
- import { Mastra } from '@mastra/core'
22
- import { Observability, CloudExporter } from '@mastra/observability'
23
-
24
- export const mastra = new Mastra({
25
- observability: new Observability({
26
- configs: {
27
- production: {
28
- serviceName: 'my-service',
29
- exporters: [
30
- new CloudExporter(), // Uses MASTRA_CLOUD_ACCESS_TOKEN env var
31
- ],
32
- },
33
- },
34
- }),
35
- })
36
- ```
37
-
38
- ### Recommended Configuration
39
-
40
- Include CloudExporter in your observability configuration:
41
-
42
- ```typescript
43
- import { Mastra } from '@mastra/core'
44
- import {
45
- Observability,
46
- DefaultExporter,
47
- CloudExporter,
48
- SensitiveDataFilter,
49
- } from '@mastra/observability'
50
-
51
- export const mastra = new Mastra({
52
- observability: new Observability({
53
- configs: {
54
- default: {
55
- serviceName: 'mastra',
56
- exporters: [
57
- new DefaultExporter(),
58
- new CloudExporter(), // Sends traces to Mastra Cloud (requires MASTRA_CLOUD_ACCESS_TOKEN)
59
- ],
60
- spanOutputProcessors: [new SensitiveDataFilter()],
61
- },
62
- },
63
- }),
64
- })
65
- ```
66
-
67
- ### Complete Configuration
68
-
69
- ```typescript
70
- new CloudExporter({
71
- // Optional - defaults to env var
72
- accessToken: process.env.MASTRA_CLOUD_ACCESS_TOKEN,
73
-
74
- // Optional - for self-hosted Mastra Cloud
75
- endpoint: 'https://cloud.your-domain.com',
76
-
77
- // Batching configuration
78
- maxBatchSize: 1000, // Max spans per batch
79
- maxBatchWaitMs: 5000, // Max wait before sending batch
80
-
81
- // Diagnostic logging
82
- logLevel: 'info', // debug | info | warn | error
83
- })
84
- ```
85
-
86
- ## Viewing traces
87
-
88
- ### Mastra Cloud Dashboard
89
-
90
- 1. Navigate to [cloud.mastra.ai](https://cloud.mastra.ai)
91
-
92
- 2. Select the project associated with your access token
93
-
94
- 3. Go to **Observability → Traces**
95
-
96
- 4. Use filters to find specific traces:
97
-
98
- - Service name
99
- - Time range
100
- - Trace ID
101
- - Error status
102
-
103
- > **Note:** Traces are scoped to the project that issued the access token. To view traces, make sure you're viewing the same project you generated the token from.
104
-
105
- ### Features
106
-
107
- - **Trace Timeline** - Visual execution flow
108
- - **Span Details** - Inputs, outputs, metadata
109
- - **Performance Metrics** - Latency, token usage
110
- - **Team Collaboration** - Share trace links
111
-
112
- ## Performance
113
-
114
- > **Info:** CloudExporter uses intelligent batching to optimize network usage. Traces are buffered and sent in batches, reducing overhead while maintaining near real-time visibility.
115
-
116
- ### Batching Behavior
117
-
118
- - Traces are batched up to `maxBatchSize` (default: 1000)
119
- - Batches are sent when full or after `maxBatchWaitMs` (default: 5 seconds)
120
- - Failed batches are retried with exponential backoff
121
- - Graceful degradation if Mastra Cloud is unreachable
122
-
123
- ## Related
124
-
125
- - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
126
- - [DefaultExporter](https://mastra.ai/docs/observability/tracing/exporters/default)
127
- - [Mastra Cloud Documentation](https://mastra.ai/docs/mastra-cloud/overview)
@@ -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/)