@mastra/mcp-docs-server 1.1.32 → 1.1.33-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.
- package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
- package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/vivgrid.md +4 -3
- package/.docs/models/providers/xai.md +2 -1
- package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
- package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
- package/CHANGELOG.md +8 -0
- package/package.json +5 -5
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Datadog bridge
|
|
2
|
+
|
|
3
|
+
> **Warning:** The Datadog Bridge is currently **experimental**. APIs and configuration options may change in future releases.
|
|
4
|
+
|
|
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
|
+
|
|
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.
|
|
8
|
+
|
|
9
|
+
## When to use the bridge
|
|
10
|
+
|
|
11
|
+
Use the DatadogBridge when you:
|
|
12
|
+
|
|
13
|
+
- Use `dd-trace` auto-instrumentation in your application (HTTP servers, database clients, etc.)
|
|
14
|
+
- Want APM service calls made by tools, MCP tools, or output processors to appear under their parent Mastra span instead of the request handler
|
|
15
|
+
- Need both APM traces and LLM Observability data to share a consistent trace topology
|
|
16
|
+
- Are building a distributed system where Datadog trace context must propagate across services
|
|
17
|
+
|
|
18
|
+
## How it works
|
|
19
|
+
|
|
20
|
+
The DatadogBridge participates in two parts of the dd-trace pipeline:
|
|
21
|
+
|
|
22
|
+
**APM context propagation (real time):**
|
|
23
|
+
|
|
24
|
+
- Creates a dd-trace APM span via `tracer.startSpan()` when each Mastra span is created
|
|
25
|
+
- Activates the APM span in dd-trace's scope via `tracer.scope().activate()` during execution
|
|
26
|
+
- Auto-instrumented operations inside the active scope are parented to the correct Mastra span
|
|
27
|
+
- Inherits the active dd-trace context (e.g., an incoming request span) when no explicit Mastra parent exists
|
|
28
|
+
|
|
29
|
+
**LLM Observability emission (on span end):**
|
|
30
|
+
|
|
31
|
+
- Emits annotations (model info, token usage, input/output, errors) through `dd-trace`'s LLM Observability pipeline
|
|
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)
|
|
34
|
+
|
|
35
|
+
## Why this matters
|
|
36
|
+
|
|
37
|
+
Without the bridge, the Datadog Exporter only creates LLM Observability spans after a trace completes. During execution, no `dd-trace` span is active in scope, so any HTTP or database call made by a tool falls back to whatever `dd-trace` span is active at the time — typically the incoming request handler. The result is that service calls from MCP tools or output processors appear as children of the request span instead of the agent or processor span that actually made them.
|
|
38
|
+
|
|
39
|
+
The bridge fixes this by creating real dd-trace spans up front, so the scope is correct when auto-instrumentation runs.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
**npm**:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install @mastra/datadog dd-trace
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**pnpm**:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pnpm add @mastra/datadog dd-trace
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Yarn**:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
yarn add @mastra/datadog dd-trace
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Bun**:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bun add @mastra/datadog dd-trace
|
|
65
|
+
```
|
|
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.
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
Using the DatadogBridge requires two steps:
|
|
72
|
+
|
|
73
|
+
1. Initialize `dd-trace` so its auto-instrumentation patches HTTP, database, and framework libraries
|
|
74
|
+
2. Add the DatadogBridge to your Mastra observability config
|
|
75
|
+
|
|
76
|
+
### Step 1: Initialize dd-trace
|
|
77
|
+
|
|
78
|
+
`dd-trace` must be initialized before any other imports so its auto-instrumentation can patch libraries at load time. The bridge will detect an already-initialized tracer and reuse it.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import tracer from 'dd-trace'
|
|
82
|
+
|
|
83
|
+
tracer.init({
|
|
84
|
+
service: process.env.DD_SERVICE || 'my-mastra-app',
|
|
85
|
+
env: process.env.DD_ENV || 'production',
|
|
86
|
+
version: process.env.DD_VERSION,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
import { Mastra } from '@mastra/core'
|
|
90
|
+
import { Observability } from '@mastra/observability'
|
|
91
|
+
import { DatadogBridge } from '@mastra/datadog'
|
|
92
|
+
|
|
93
|
+
// ...
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
> **Note:** Import and initialize `dd-trace` at the very top of your application's entry file, before any other imports.
|
|
97
|
+
|
|
98
|
+
### Step 2: Mastra Configuration
|
|
99
|
+
|
|
100
|
+
Add the DatadogBridge to your Mastra observability config:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
export const mastra = new Mastra({
|
|
104
|
+
observability: new Observability({
|
|
105
|
+
configs: {
|
|
106
|
+
default: {
|
|
107
|
+
serviceName: 'my-mastra-app',
|
|
108
|
+
bridge: new DatadogBridge({
|
|
109
|
+
mlApp: process.env.DD_LLMOBS_ML_APP!,
|
|
110
|
+
}),
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
bundler: {
|
|
115
|
+
externals: [
|
|
116
|
+
'dd-trace',
|
|
117
|
+
'@datadog/native-metrics',
|
|
118
|
+
'@datadog/native-appsec',
|
|
119
|
+
'@datadog/native-iast-taint-tracking',
|
|
120
|
+
'@datadog/pprof',
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
DD_SERVICE=my-mastra-app
|
|
128
|
+
DD_ENV=production
|
|
129
|
+
DD_VERSION=1.0.0
|
|
130
|
+
DD_LLMOBS_ML_APP=my-llm-app
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
When `dd-trace` is initialized, it routes APM data to your local Datadog Agent on `localhost:8126`. The bridge enables LLM Observability on top of the same tracer, so both sets of data appear under the same service in Datadog.
|
|
134
|
+
|
|
135
|
+
No Mastra exporters are required when using the bridge — both APM and LLM Observability data flow through `dd-trace`. You can still add Mastra exporters if you want to send traces to additional destinations.
|
|
136
|
+
|
|
137
|
+
## Agent vs. agentless mode
|
|
138
|
+
|
|
139
|
+
The bridge defaults to **agent mode** (`agentless: false`). This assumes a local Datadog Agent is running on `localhost:8126` to receive both APM and LLM Observability data. This is the typical setup when using `dd-trace` auto-instrumentation, since APM data always routes through the agent.
|
|
140
|
+
|
|
141
|
+
If you don't have a local Datadog Agent and only need LLM Observability data (no APM auto-instrumentation), you can enable agentless mode to send data directly to Datadog. In this case, you must provide an API key.
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
new DatadogBridge({
|
|
145
|
+
mlApp: process.env.DD_LLMOBS_ML_APP!,
|
|
146
|
+
apiKey: process.env.DD_API_KEY!,
|
|
147
|
+
agentless: true,
|
|
148
|
+
})
|
|
149
|
+
```
|
|
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.
|
|
152
|
+
|
|
153
|
+
## Trace hierarchy
|
|
154
|
+
|
|
155
|
+
With the DatadogBridge, your traces maintain proper hierarchy across dd-trace and Mastra boundaries. Service calls made by tools and processors appear under the correct Mastra span:
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
HTTP POST /api/chat (from web framework instrumentation)
|
|
159
|
+
└── agent.orchestrator (from Mastra via DatadogBridge)
|
|
160
|
+
├── chat gpt-5.4 (LLM call)
|
|
161
|
+
├── tool.execute search (tool execution)
|
|
162
|
+
│ └── HTTP GET api.example.com (auto-instrumented from inside the tool)
|
|
163
|
+
└── processor.guardrail (output processor)
|
|
164
|
+
└── HTTP POST guardrail-service/check (auto-instrumented from inside the processor)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
In Datadog, the APM trace shows this full topology, and the LLM Observability product shows the agent and LLM-specific spans with their inputs, outputs, and token metrics.
|
|
168
|
+
|
|
169
|
+
## Span type mapping
|
|
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.
|
|
172
|
+
|
|
173
|
+
## Using tags
|
|
174
|
+
|
|
175
|
+
Tags help you categorize and filter traces in Datadog. Add tags when executing agents or workflows:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
const result = await agent.generate('Hello', {
|
|
179
|
+
tracingOptions: {
|
|
180
|
+
tags: ['production', 'experiment-v2', 'user-request'],
|
|
181
|
+
},
|
|
182
|
+
})
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Tags formatted as `key:value` (e.g., `instance_name:career-scout-api`) are split into structured tag entries; tags without a colon are set with a `true` value.
|
|
186
|
+
|
|
187
|
+
## Promoting context keys to flat tags
|
|
188
|
+
|
|
189
|
+
Use `requestContextKeys` to promote specific keys from the request context or span attributes into flat, indexable LLM Observability tags. This makes them filterable in the Datadog UI:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
new DatadogBridge({
|
|
193
|
+
mlApp: process.env.DD_LLMOBS_ML_APP!,
|
|
194
|
+
requestContextKeys: ['tenantId', 'agentId'],
|
|
195
|
+
})
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Promoted keys are removed from `annotations.metadata` and added as flat tags on each LLM Observability span.
|
|
199
|
+
|
|
200
|
+
## Troubleshooting
|
|
201
|
+
|
|
202
|
+
If APM spans aren't connecting to Mastra spans as expected:
|
|
203
|
+
|
|
204
|
+
- Verify `dd-trace` is initialized **before** any other imports (it patches libraries at load time)
|
|
205
|
+
- Verify a local Datadog Agent is running and reachable at `localhost:8126`
|
|
206
|
+
- Ensure the DatadogBridge is set as `bridge` (not as an entry in `exporters`) in your observability config
|
|
207
|
+
- Confirm you haven't also added the `DatadogExporter` to `exporters` — using both will double-emit LLM Observability data
|
|
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.
|
|
210
|
+
|
|
211
|
+
## Related
|
|
212
|
+
|
|
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
|
|
215
|
+
- [DatadogBridge Reference](https://mastra.ai/reference/observability/tracing/bridges/datadog) - API documentation
|
|
216
|
+
- [Datadog APM documentation](https://docs.datadoghq.com/tracing/)
|
|
217
|
+
- [Datadog LLM Observability documentation](https://docs.datadoghq.com/llm_observability/)
|
|
@@ -2,6 +2,8 @@
|
|
|
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.
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
**npm**:
|
|
@@ -130,7 +132,7 @@ Note: When using agent mode, the API key is read from the local agent's configur
|
|
|
130
132
|
|
|
131
133
|
## Span type mapping
|
|
132
134
|
|
|
133
|
-
Mastra span types are automatically mapped to Datadog
|
|
135
|
+
Mastra span types are automatically mapped to Datadog LLM Observability span kinds:
|
|
134
136
|
|
|
135
137
|
| Mastra SpanType | Datadog Kind |
|
|
136
138
|
| -------------------- | ------------ |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3805 models from 106 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vivgrid
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 13 Vivgrid models through Mastra's model router. Authentication is handled automatically using the `VIVGRID_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Vivgrid documentation](https://docs.vivgrid.com/models).
|
|
6
6
|
|
|
@@ -35,9 +35,9 @@ for await (const chunk of stream) {
|
|
|
35
35
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
36
|
| --------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
37
|
| `vivgrid/deepseek-v3.2` | 128K | | | | | | $0.28 | $0.42 |
|
|
38
|
+
| `vivgrid/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 |
|
|
38
39
|
| `vivgrid/gemini-3.1-flash-lite-preview` | 1.0M | | | | | | $0.25 | $2 |
|
|
39
40
|
| `vivgrid/gemini-3.1-pro-preview` | 1.0M | | | | | | $2 | $12 |
|
|
40
|
-
| `vivgrid/glm-5` | 203K | | | | | | $1 | $3 |
|
|
41
41
|
| `vivgrid/gpt-5-mini` | 272K | | | | | | $0.25 | $2 |
|
|
42
42
|
| `vivgrid/gpt-5.1-codex` | 400K | | | | | | $1 | $10 |
|
|
43
43
|
| `vivgrid/gpt-5.1-codex-max` | 400K | | | | | | $1 | $10 |
|
|
@@ -46,6 +46,7 @@ for await (const chunk of stream) {
|
|
|
46
46
|
| `vivgrid/gpt-5.4` | 400K | | | | | | $3 | $15 |
|
|
47
47
|
| `vivgrid/gpt-5.4-mini` | 400K | | | | | | $0.75 | $5 |
|
|
48
48
|
| `vivgrid/gpt-5.4-nano` | 400K | | | | | | $0.20 | $1 |
|
|
49
|
+
| `vivgrid/gpt-5.5` | 1.1M | | | | | | $5 | $30 |
|
|
49
50
|
|
|
50
51
|
## Advanced configuration
|
|
51
52
|
|
|
@@ -75,7 +76,7 @@ const agent = new Agent({
|
|
|
75
76
|
model: ({ requestContext }) => {
|
|
76
77
|
const useAdvanced = requestContext.task === "complex";
|
|
77
78
|
return useAdvanced
|
|
78
|
-
? "vivgrid/gpt-5.
|
|
79
|
+
? "vivgrid/gpt-5.5"
|
|
79
80
|
: "vivgrid/deepseek-v3.2";
|
|
80
81
|
}
|
|
81
82
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# xAI
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 26 xAI models through Mastra's model router. Authentication is handled automatically using the `XAI_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [xAI documentation](https://docs.x.ai/docs/models).
|
|
6
6
|
|
|
@@ -54,6 +54,7 @@ for await (const chunk of stream) {
|
|
|
54
54
|
| `xai/grok-4.20-0309-non-reasoning` | 2.0M | | | | | | $2 | $6 |
|
|
55
55
|
| `xai/grok-4.20-0309-reasoning` | 2.0M | | | | | | $2 | $6 |
|
|
56
56
|
| `xai/grok-4.20-multi-agent-0309` | 2.0M | | | | | | $2 | $6 |
|
|
57
|
+
| `xai/grok-4.3` | 1.0M | | | | | | $1 | $3 |
|
|
57
58
|
| `xai/grok-beta` | 131K | | | | | | $5 | $15 |
|
|
58
59
|
| `xai/grok-code-fast-1` | 256K | | | | | | $0.20 | $2 |
|
|
59
60
|
| `xai/grok-vision-beta` | 8K | | | | | | $5 | $15 |
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# DatadogBridge
|
|
2
|
+
|
|
3
|
+
> **Warning:** The Datadog Bridge is currently **experimental**. APIs and configuration options may change in future releases.
|
|
4
|
+
|
|
5
|
+
Enables bidirectional integration between Mastra tracing and Datadog. Creates native `dd-trace` APM spans in real time so that auto-instrumented operations inside tools and processors are correctly nested under their parent Mastra span. Emits LLM Observability data through `dd-trace`'s pipeline when spans end.
|
|
6
|
+
|
|
7
|
+
## Constructor
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
new DatadogBridge(config?: DatadogBridgeConfig)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## `DatadogBridgeConfig`
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
interface DatadogBridgeConfig extends BaseExporterConfig {
|
|
17
|
+
apiKey?: string
|
|
18
|
+
mlApp?: string
|
|
19
|
+
site?: string
|
|
20
|
+
service?: string
|
|
21
|
+
env?: string
|
|
22
|
+
agentless?: boolean
|
|
23
|
+
integrationsEnabled?: boolean
|
|
24
|
+
requestContextKeys?: string[]
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Extends `BaseExporterConfig`, which includes:
|
|
29
|
+
|
|
30
|
+
- `logger?: IMastraLogger` - Logger instance
|
|
31
|
+
- `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: INFO)
|
|
32
|
+
|
|
33
|
+
## Methods
|
|
34
|
+
|
|
35
|
+
### `createSpan`
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
createSpan(options: CreateSpanOptions<SpanType>): SpanIds | undefined
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Called by the Mastra observability instance during span construction. Creates a dd-trace APM span eagerly via `tracer.startSpan()` and returns Mastra-compatible identifiers. The returned IDs are used by Mastra throughout the span's lifetime; the dd-trace span object is stored internally and used for scope activation.
|
|
42
|
+
|
|
43
|
+
**Returns:** `SpanIds | undefined` - `{ spanId, traceId, parentSpanId }`, or `undefined` if the bridge is disabled.
|
|
44
|
+
|
|
45
|
+
### `executeInContext`
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
executeInContext<T>(spanId: string, fn: () => Promise<T>): Promise<T>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Executes an async function within the dd-trace context of a Mastra span. dd-trace auto-instrumented operations running inside the function (HTTP, database, etc.) will be parented to this span.
|
|
52
|
+
|
|
53
|
+
**Returns:** `Promise<T>` - The result of the function execution.
|
|
54
|
+
|
|
55
|
+
### `executeInContextSync`
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
executeInContextSync<T>(spanId: string, fn: () => T): T
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Executes a synchronous function within the dd-trace context of a Mastra span.
|
|
62
|
+
|
|
63
|
+
**Returns:** `T` - The result of the function execution.
|
|
64
|
+
|
|
65
|
+
### `flush`
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
async flush(): Promise<void>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Force-flushes any buffered LLM Observability data to Datadog without shutting down the bridge. Useful in serverless environments where you need to ensure data is exported before the runtime terminates.
|
|
72
|
+
|
|
73
|
+
### `shutdown`
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
async shutdown(): Promise<void>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Force-finishes any APM spans that weren't properly closed, flushes pending LLM Observability data, disables the LLM Observability integration, and clears all internal state.
|
|
80
|
+
|
|
81
|
+
## Usage examples
|
|
82
|
+
|
|
83
|
+
### Basic Usage
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import tracer from 'dd-trace'
|
|
87
|
+
|
|
88
|
+
tracer.init({
|
|
89
|
+
service: process.env.DD_SERVICE || 'my-mastra-app',
|
|
90
|
+
env: process.env.DD_ENV || 'production',
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
import { Mastra } from '@mastra/core'
|
|
94
|
+
import { Observability } from '@mastra/observability'
|
|
95
|
+
import { DatadogBridge } from '@mastra/datadog'
|
|
96
|
+
|
|
97
|
+
const mastra = new Mastra({
|
|
98
|
+
observability: new Observability({
|
|
99
|
+
configs: {
|
|
100
|
+
default: {
|
|
101
|
+
serviceName: 'my-mastra-app',
|
|
102
|
+
bridge: new DatadogBridge({
|
|
103
|
+
mlApp: process.env.DD_LLMOBS_ML_APP!,
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
agents: { myAgent },
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Agentless Mode (LLM Observability only, no local agent)
|
|
113
|
+
|
|
114
|
+
If you don't have a local Datadog Agent and only want LLM Observability data, enable agentless mode:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
new DatadogBridge({
|
|
118
|
+
mlApp: process.env.DD_LLMOBS_ML_APP!,
|
|
119
|
+
apiKey: process.env.DD_API_KEY!,
|
|
120
|
+
agentless: true,
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Note: APM data cannot be sent in agentless mode. If you only need LLM Observability data without `dd-trace` APM, the [Datadog Exporter](https://mastra.ai/reference/observability/tracing/exporters/datadog) is a simpler choice.
|
|
125
|
+
|
|
126
|
+
### With Additional Exporters
|
|
127
|
+
|
|
128
|
+
The bridge can be combined with non-Datadog exporters to send traces to additional destinations:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { Mastra } from '@mastra/core'
|
|
132
|
+
import { Observability, DefaultExporter } from '@mastra/observability'
|
|
133
|
+
import { DatadogBridge } from '@mastra/datadog'
|
|
134
|
+
|
|
135
|
+
const mastra = new Mastra({
|
|
136
|
+
observability: new Observability({
|
|
137
|
+
configs: {
|
|
138
|
+
default: {
|
|
139
|
+
serviceName: 'my-mastra-app',
|
|
140
|
+
bridge: new DatadogBridge({
|
|
141
|
+
mlApp: process.env.DD_LLMOBS_ML_APP!,
|
|
142
|
+
}),
|
|
143
|
+
exporters: [
|
|
144
|
+
new DefaultExporter(), // Studio access
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
}),
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
> **Note:** Don't combine `DatadogBridge` with `DatadogExporter` in the same configuration — both emit to LLM Observability and would double-write the same data.
|
|
153
|
+
|
|
154
|
+
## Setup requirements
|
|
155
|
+
|
|
156
|
+
The DatadogBridge requires `dd-trace` to be initialized before any other imports so its auto-instrumentation can patch HTTP, database, and framework libraries at load time.
|
|
157
|
+
|
|
158
|
+
See the [DatadogBridge Guide](https://mastra.ai/docs/observability/tracing/bridges/datadog) for complete setup instructions, including dd-trace initialization, bundler externals, and agent configuration.
|
|
159
|
+
|
|
160
|
+
## Span mapping
|
|
161
|
+
|
|
162
|
+
Mastra span types are mapped to Datadog LLM Observability span kinds:
|
|
163
|
+
|
|
164
|
+
| Mastra SpanType | Datadog Kind |
|
|
165
|
+
| ------------------ | ------------ |
|
|
166
|
+
| `AGENT_RUN` | `agent` |
|
|
167
|
+
| `MODEL_GENERATION` | `workflow` |
|
|
168
|
+
| `MODEL_STEP` | `llm` |
|
|
169
|
+
| `TOOL_CALL` | `tool` |
|
|
170
|
+
| `MCP_TOOL_CALL` | `tool` |
|
|
171
|
+
| `WORKFLOW_RUN` | `workflow` |
|
|
172
|
+
| All other types | `task` |
|
|
173
|
+
|
|
174
|
+
## Tags support
|
|
175
|
+
|
|
176
|
+
`tracingOptions.tags` values become structured LLM Observability annotation tags: `key:value` entries are split into key/value pairs, and tags without a colon are set to `true`.
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
const result = await agent.generate('Hello', {
|
|
180
|
+
tracingOptions: {
|
|
181
|
+
tags: ['production', 'instance_name:career-scout-api'],
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
This produces:
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"production": true,
|
|
191
|
+
"instance_name": "career-scout-api"
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Environment variables
|
|
196
|
+
|
|
197
|
+
The bridge reads configuration from these environment variables:
|
|
198
|
+
|
|
199
|
+
| Variable | Description |
|
|
200
|
+
| ----------------------------- | -------------------------------------------------- |
|
|
201
|
+
| `DD_API_KEY` | Datadog API key (only required for agentless mode) |
|
|
202
|
+
| `DD_LLMOBS_ML_APP` | ML application name |
|
|
203
|
+
| `DD_SITE` | Datadog site |
|
|
204
|
+
| `DD_ENV` | Environment name |
|
|
205
|
+
| `DD_LLMOBS_AGENTLESS_ENABLED` | Set to `'true'` or `'1'` to enable agentless mode |
|
|
206
|
+
|
|
207
|
+
## Related
|
|
208
|
+
|
|
209
|
+
- [DatadogBridge Guide](https://mastra.ai/docs/observability/tracing/bridges/datadog) - Setup guide with examples
|
|
210
|
+
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview) - General tracing concepts
|
|
211
|
+
- [DatadogExporter Reference](https://mastra.ai/reference/observability/tracing/exporters/datadog) - LLM Observability only, no `dd-trace` APM
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Sends Tracing data to Datadog's LLM Observability product for monitoring and analytics.
|
|
4
4
|
|
|
5
|
+
> **Info:** If you also use `dd-trace` APM auto-instrumentation and need it correctly parented under Mastra spans, use the [DatadogBridge](https://mastra.ai/reference/observability/tracing/bridges/datadog) instead. The exporter sends LLM Observability data after execution completes, so it doesn't participate in `dd-trace`'s live scope.
|
|
6
|
+
|
|
5
7
|
## Constructor
|
|
6
8
|
|
|
7
9
|
```typescript
|
|
@@ -89,7 +91,7 @@ const exporter = new DatadogExporter({
|
|
|
89
91
|
|
|
90
92
|
## Span mapping
|
|
91
93
|
|
|
92
|
-
Mastra span types are mapped to Datadog
|
|
94
|
+
Mastra span types are mapped to Datadog LLM Observability span kinds:
|
|
93
95
|
|
|
94
96
|
| Mastra SpanType | Datadog Kind |
|
|
95
97
|
| ------------------ | ------------ |
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.33-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c), [`568777e`](https://github.com/mastra-ai/mastra/commit/568777ea8af77a672270b448dfd3996f9e75a964)]:
|
|
8
|
+
- @mastra/core@1.31.1-alpha.0
|
|
9
|
+
- @mastra/mcp@1.6.1-alpha.0
|
|
10
|
+
|
|
3
11
|
## 1.1.32
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.33-alpha.1",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/core": "1.31.0",
|
|
33
|
-
"@mastra/mcp": "^1.6.0"
|
|
32
|
+
"@mastra/core": "1.31.1-alpha.0",
|
|
33
|
+
"@mastra/mcp": "^1.6.1-alpha.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"tsx": "^4.21.0",
|
|
47
47
|
"typescript": "^6.0.3",
|
|
48
48
|
"vitest": "4.1.5",
|
|
49
|
-
"@internal/lint": "0.0.90",
|
|
50
49
|
"@internal/types-builder": "0.0.65",
|
|
51
|
-
"@mastra/core": "1.31.0"
|
|
50
|
+
"@mastra/core": "1.31.1-alpha.0",
|
|
51
|
+
"@internal/lint": "0.0.90"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|