@mastra/mcp-docs-server 0.0.0-studio-deploy-20260404182525 → 0.0.0-studio-cli-20260504022012
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/adding-voice.md +18 -17
- package/.docs/docs/agents/background-tasks.md +242 -0
- package/.docs/docs/agents/channels.md +2 -1
- package/.docs/docs/agents/overview.md +4 -0
- package/.docs/docs/agents/processors.md +177 -5
- package/.docs/docs/agents/structured-output.md +66 -1
- package/.docs/docs/agents/supervisor-agents.md +65 -0
- package/.docs/docs/agents/using-tools.md +73 -0
- package/.docs/docs/browser/agent-browser.md +78 -0
- package/.docs/docs/browser/browser-viewer.md +144 -0
- package/.docs/docs/browser/overview.md +168 -0
- package/.docs/docs/browser/stagehand.md +129 -0
- package/.docs/docs/deployment/cloud-providers.md +5 -1
- package/.docs/docs/deployment/mastra-server.md +4 -4
- package/.docs/docs/deployment/monorepo.md +3 -3
- package/.docs/docs/deployment/overview.md +11 -8
- package/.docs/docs/editor/overview.md +290 -0
- package/.docs/docs/editor/prompts.md +134 -0
- package/.docs/docs/editor/tools.md +152 -0
- package/.docs/docs/evals/custom-scorers.md +63 -3
- package/.docs/docs/evals/datasets/overview.md +1 -1
- package/.docs/docs/index.md +2 -2
- package/.docs/docs/mastra-platform/configuration.md +36 -0
- package/.docs/docs/mastra-platform/overview.md +78 -0
- package/.docs/docs/mcp/overview.md +17 -0
- package/.docs/docs/memory/memory-processors.md +3 -3
- package/.docs/docs/memory/message-history.md +8 -2
- package/.docs/docs/memory/observational-memory.md +65 -8
- package/.docs/docs/memory/storage.md +1 -2
- package/.docs/docs/memory/working-memory.md +2 -2
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +2 -2
- package/.docs/docs/observability/overview.md +1 -1
- package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
- package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
- package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
- package/.docs/docs/observability/tracing/exporters/cloud.md +135 -63
- package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
- package/.docs/docs/observability/tracing/exporters/default.md +5 -5
- package/.docs/docs/observability/tracing/exporters/laminar.md +22 -14
- package/.docs/docs/observability/tracing/exporters/langfuse.md +50 -33
- package/.docs/docs/observability/tracing/overview.md +87 -20
- package/.docs/docs/server/custom-adapters.md +5 -5
- package/.docs/docs/server/custom-api-routes.md +3 -3
- package/.docs/docs/server/mastra-client.md +2 -2
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/middleware.md +46 -42
- package/.docs/docs/server/request-context.md +13 -2
- package/.docs/docs/server/server-adapters.md +91 -8
- package/.docs/docs/streaming/background-task-streaming.md +80 -0
- package/.docs/docs/streaming/overview.md +3 -0
- package/.docs/docs/studio/deployment.md +24 -6
- package/.docs/docs/studio/observability.md +1 -1
- package/.docs/docs/studio/overview.md +4 -4
- package/.docs/docs/voice/overview.md +74 -5
- package/.docs/docs/voice/speech-to-speech.md +45 -1
- package/.docs/docs/voice/speech-to-text.md +7 -7
- package/.docs/docs/voice/text-to-speech.md +10 -10
- package/.docs/docs/workflows/agents-and-tools.md +1 -1
- package/.docs/docs/workflows/overview.md +105 -4
- package/.docs/docs/workflows/scheduled-workflows.md +181 -0
- package/.docs/docs/workspace/filesystem.md +64 -6
- package/.docs/docs/workspace/lsp.md +76 -4
- package/.docs/docs/workspace/overview.md +62 -15
- package/.docs/docs/workspace/sandbox.md +3 -1
- package/.docs/docs/workspace/search.md +41 -2
- package/.docs/docs/workspace/skills.md +19 -19
- package/.docs/guides/agent-frameworks/ai-sdk.md +4 -4
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +56 -9
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/deployment/mastra-platform.md +191 -0
- package/.docs/guides/deployment/netlify.md +16 -1
- package/.docs/guides/getting-started/nestjs.md +238 -0
- package/.docs/guides/getting-started/next-js.md +0 -4
- package/.docs/guides/guide/code-review-bot.md +2 -2
- package/.docs/guides/guide/dev-assistant.md +4 -4
- package/.docs/{docs/mcp → guides/guide}/publishing-mcp-server.md +21 -1
- package/.docs/guides/guide/slack-assistant.md +191 -0
- package/.docs/guides/migrations/mastra-cloud.md +368 -0
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
- package/.docs/models/embeddings.md +3 -3
- package/.docs/models/gateways/azure-openai.md +74 -35
- package/.docs/models/gateways/mastra.md +64 -0
- package/.docs/models/gateways/netlify.md +7 -3
- package/.docs/models/gateways/openrouter.md +28 -12
- package/.docs/models/gateways/vercel.md +22 -2
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +43 -8
- package/.docs/models/providers/302ai.md +37 -4
- package/.docs/models/providers/abliteration-ai.md +71 -0
- package/.docs/models/providers/alibaba-cn.md +8 -2
- package/.docs/models/providers/alibaba-coding-plan-cn.md +3 -2
- package/.docs/models/providers/alibaba-coding-plan.md +3 -2
- package/.docs/models/providers/alibaba.md +8 -1
- package/.docs/models/providers/anthropic.md +18 -5
- package/.docs/models/providers/baseten.md +3 -1
- package/.docs/models/providers/berget.md +10 -12
- package/.docs/models/providers/chutes.md +4 -2
- package/.docs/models/providers/cloudflare-workers-ai.md +14 -48
- package/.docs/models/providers/cortecs.md +22 -2
- package/.docs/models/providers/deepinfra.md +8 -2
- package/.docs/models/providers/deepseek.md +6 -4
- package/.docs/models/providers/digitalocean.md +133 -0
- package/.docs/models/providers/fireworks-ai.md +6 -1
- package/.docs/models/providers/firmware.md +12 -10
- package/.docs/models/providers/friendli.md +6 -7
- package/.docs/models/providers/google.md +9 -3
- package/.docs/models/providers/helicone.md +1 -2
- package/.docs/models/providers/hpc-ai.md +73 -0
- package/.docs/models/providers/huggingface.md +6 -2
- package/.docs/models/providers/inception.md +9 -11
- package/.docs/models/providers/kilo.md +359 -339
- package/.docs/models/providers/kimi-for-coding.md +2 -1
- package/.docs/models/providers/llmgateway.md +67 -77
- package/.docs/models/providers/mistral.md +3 -2
- package/.docs/models/providers/mixlayer.md +75 -0
- package/.docs/models/providers/moonshotai-cn.md +3 -2
- package/.docs/models/providers/moonshotai.md +3 -2
- package/.docs/models/providers/nano-gpt.md +8 -2
- package/.docs/models/providers/neuralwatt.md +84 -0
- package/.docs/models/providers/novita-ai.md +19 -4
- package/.docs/models/providers/nvidia.md +8 -1
- package/.docs/models/providers/ollama-cloud.md +7 -2
- package/.docs/models/providers/openai.md +7 -2
- package/.docs/models/providers/opencode-go.md +21 -13
- package/.docs/models/providers/opencode.md +11 -4
- package/.docs/models/providers/ovhcloud.md +6 -8
- package/.docs/models/providers/poe.md +10 -15
- package/.docs/models/providers/regolo-ai.md +83 -0
- package/.docs/models/providers/siliconflow-cn.md +5 -2
- package/.docs/models/providers/siliconflow.md +6 -3
- package/.docs/models/providers/stepfun.md +8 -7
- package/.docs/models/providers/synthetic.md +5 -2
- package/.docs/models/providers/tencent-token-plan.md +71 -0
- package/.docs/models/providers/tencent-tokenhub.md +71 -0
- package/.docs/models/providers/togetherai.md +8 -7
- package/.docs/models/providers/vivgrid.md +7 -3
- package/.docs/models/providers/vultr.md +7 -6
- package/.docs/models/providers/wafer.ai.md +73 -0
- package/.docs/models/providers/wandb.md +3 -2
- package/.docs/models/providers/xai.md +6 -1
- package/.docs/models/providers/xiaomi-token-plan-ams.md +75 -0
- package/.docs/models/providers/xiaomi-token-plan-cn.md +75 -0
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +75 -0
- package/.docs/models/providers/xiaomi.md +4 -2
- package/.docs/models/providers/zai-coding-plan.md +11 -19
- package/.docs/models/providers/zai.md +2 -1
- package/.docs/models/providers/zenmux.md +17 -6
- package/.docs/models/providers/zhipuai-coding-plan.md +11 -21
- package/.docs/models/providers/zhipuai.md +2 -1
- package/.docs/models/providers.md +11 -0
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/channels.md +3 -3
- package/.docs/reference/agents/generate.md +88 -6
- package/.docs/reference/agents/generateLegacy.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +2 -0
- package/.docs/reference/ai-sdk/handle-chat-stream.md +19 -0
- package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
- package/.docs/reference/ai-sdk/network-route.md +2 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +15 -0
- package/.docs/reference/browser/agent-browser.md +375 -0
- package/.docs/reference/browser/browser-viewer.md +228 -0
- package/.docs/reference/browser/mastra-browser.md +286 -0
- package/.docs/reference/browser/stagehand-browser.md +286 -0
- package/.docs/reference/cli/mastra.md +703 -0
- package/.docs/reference/client-js/agents.md +166 -0
- package/.docs/reference/client-js/conversations.md +1 -1
- package/.docs/reference/client-js/mastra-client.md +23 -0
- package/.docs/reference/client-js/observability.md +2 -2
- package/.docs/reference/client-js/responses.md +1 -1
- package/.docs/reference/client-js/workflows.md +62 -1
- package/.docs/reference/configuration.md +67 -1
- package/.docs/reference/core/addGateway.md +5 -5
- package/.docs/reference/core/getEditor.md +35 -0
- package/.docs/reference/core/getGateway.md +5 -5
- package/.docs/reference/core/getGatewayById.md +5 -5
- package/.docs/reference/core/getMCPServer.md +2 -2
- package/.docs/reference/core/getMCPServerById.md +2 -2
- package/.docs/reference/core/getScorer.md +3 -3
- package/.docs/reference/core/getScorerById.md +3 -3
- package/.docs/reference/core/listGateways.md +5 -5
- package/.docs/reference/core/listMCPServers.md +2 -2
- package/.docs/reference/core/listScorers.md +3 -3
- package/.docs/reference/core/mastra-class.md +11 -1
- package/.docs/reference/core/mastra-model-gateway.md +5 -5
- package/.docs/reference/datasets/create.md +4 -4
- package/.docs/reference/datasets/startExperiment.md +28 -2
- package/.docs/reference/datasets/update.md +4 -4
- package/.docs/reference/deployer/cloudflare.md +14 -1
- package/.docs/reference/deployer/netlify.md +50 -2
- package/.docs/reference/editor/mastra-editor.md +168 -0
- package/.docs/reference/editor/tool-provider.md +85 -0
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-relevance.md +3 -3
- package/.docs/reference/evals/create-scorer.md +5 -3
- package/.docs/reference/evals/filter-run.md +117 -0
- package/.docs/reference/evals/mastra-scorer.md +4 -4
- package/.docs/reference/evals/noise-sensitivity.md +6 -6
- package/.docs/reference/evals/prompt-alignment.md +12 -12
- package/.docs/reference/evals/run-evals.md +6 -6
- package/.docs/reference/evals/scorer-utils.md +3 -3
- package/.docs/reference/evals/trajectory-accuracy.md +3 -3
- package/.docs/reference/harness/harness-class.md +152 -53
- package/.docs/reference/index.md +25 -0
- package/.docs/reference/logging/pino-logger.md +0 -2
- package/.docs/reference/mastra-platform/api.md +108 -0
- package/.docs/reference/memory/clone-utilities.md +4 -2
- package/.docs/reference/memory/cloneThread.md +4 -2
- package/.docs/reference/memory/observational-memory.md +4 -0
- package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
- package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
- package/.docs/reference/observability/tracing/bridges/otel.md +3 -3
- package/.docs/reference/observability/tracing/configuration.md +18 -11
- package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +102 -21
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +8 -8
- package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +8 -8
- package/.docs/reference/observability/tracing/exporters/langfuse.md +25 -32
- package/.docs/reference/observability/tracing/exporters/otel.md +3 -3
- package/.docs/reference/observability/tracing/instances.md +7 -7
- package/.docs/reference/observability/tracing/interfaces.md +23 -6
- package/.docs/reference/observability/tracing/span-filtering.md +95 -0
- package/.docs/reference/observability/tracing/spans.md +6 -6
- package/.docs/reference/processors/prefill-error-handler.md +70 -0
- package/.docs/reference/processors/processor-interface.md +400 -40
- package/.docs/reference/processors/skill-search-processor.md +20 -1
- package/.docs/reference/processors/stream-error-retry-processor.md +54 -0
- package/.docs/reference/processors/tool-call-filter.md +23 -0
- package/.docs/reference/server/create-route.md +3 -3
- package/.docs/reference/server/express-adapter.md +4 -4
- package/.docs/reference/server/fastify-adapter.md +4 -4
- package/.docs/reference/server/hono-adapter.md +4 -4
- package/.docs/reference/server/koa-adapter.md +4 -4
- package/.docs/reference/server/mastra-server.md +3 -3
- package/.docs/reference/server/nestjs-adapter.md +169 -0
- package/.docs/reference/server/register-api-route.md +4 -4
- package/.docs/reference/server/routes.md +11 -10
- package/.docs/reference/storage/clickhouse.md +300 -0
- package/.docs/reference/storage/cloudflare-d1.md +42 -42
- package/.docs/reference/storage/composite.md +5 -3
- package/.docs/reference/storage/duckdb.md +150 -0
- package/.docs/reference/storage/overview.md +1 -1
- package/.docs/reference/storage/redis.md +266 -0
- package/.docs/reference/streaming/ChunkType.md +143 -3
- package/.docs/reference/streaming/agents/MastraModelOutput.md +2 -2
- package/.docs/reference/streaming/agents/stream.md +10 -2
- package/.docs/reference/streaming/agents/streamUntilIdle.md +94 -0
- package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
- package/.docs/reference/templates/overview.md +88 -14
- package/.docs/reference/tools/create-tool.md +107 -5
- package/.docs/reference/tools/mcp-client.md +45 -0
- package/.docs/reference/tools/mcp-server.md +1 -3
- package/.docs/reference/tools/perplexity.md +155 -0
- package/.docs/reference/tools/tavily.md +307 -0
- package/.docs/reference/vectors/mongodb.md +0 -2
- package/.docs/reference/voice/aws-nova-sonic.md +247 -0
- package/.docs/reference/voice/cloudflare.md +3 -3
- package/.docs/reference/voice/sarvam.md +29 -23
- package/.docs/reference/voice/voice.connect.md +4 -4
- package/.docs/reference/voice/voice.listen.md +3 -3
- package/.docs/reference/workflows/run-methods/resume.md +24 -0
- package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
- package/.docs/reference/workflows/step.md +88 -7
- package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
- package/.docs/reference/workflows/workflow.md +88 -4
- package/.docs/reference/workspace/azure-blob-filesystem.md +219 -0
- package/.docs/reference/workspace/docker-sandbox.md +196 -0
- package/.docs/reference/workspace/gcs-filesystem.md +1 -0
- package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
- package/.docs/reference/workspace/modal-sandbox.md +168 -0
- package/.docs/reference/workspace/process-manager.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +80 -5
- package/.docs/reference/workspace/vercel.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +37 -6
- package/CHANGELOG.md +500 -4
- package/dist/stdio.js.map +1 -1
- package/dist/utils.d.ts +1 -4
- package/dist/utils.d.ts.map +1 -1
- package/package.json +11 -11
- package/.docs/docs/mastra-cloud/deployment.md +0 -77
- package/.docs/docs/mastra-cloud/observability.md +0 -38
- package/.docs/docs/mastra-cloud/overview.md +0 -23
- package/.docs/docs/mastra-cloud/setup.md +0 -42
|
@@ -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/)
|
|
@@ -205,5 +205,5 @@ If traces aren't displaying or connecting as expected:
|
|
|
205
205
|
## Related
|
|
206
206
|
|
|
207
207
|
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
208
|
-
- [OpenTelemetry Exporter](https://mastra.ai/docs/observability/tracing/exporters/otel)
|
|
209
|
-
- [OtelBridge Reference](https://mastra.ai/reference/observability/tracing/bridges/otel)
|
|
208
|
+
- [OpenTelemetry Exporter](https://mastra.ai/docs/observability/tracing/exporters/otel): For sending traces to OTEL backends
|
|
209
|
+
- [OtelBridge Reference](https://mastra.ai/reference/observability/tracing/bridges/otel): API documentation
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Arthur exporter
|
|
2
|
+
|
|
3
|
+
[Arthur](https://arthur.ai/) provides an observability and evaluation platform for AI applications through [Arthur Engine](https://github.com/arthur-ai/arthur-engine) (open-source). The Arthur exporter sends traces using OpenTelemetry and [OpenInference](https://github.com/Arize-ai/openinference/tree/main/spec) semantic conventions.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
**npm**:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mastra/arthur@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**pnpm**:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @mastra/arthur@latest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Yarn**:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add @mastra/arthur@latest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Bun**:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bun add @mastra/arthur@latest
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
### Prerequisites
|
|
34
|
+
|
|
35
|
+
1. **Arthur Engine instance**: Follow the [Docker Compose deployment guide](https://docs.arthur.ai/docs/arthur-genai-engine-docker-compose-deployment-guide) to start an Arthur Engine
|
|
36
|
+
2. **API key**: [Generate an API key](https://docs.arthur.ai/docs/api-keys-management) from the Arthur Engine UI at `http://localhost:3030`
|
|
37
|
+
3. **Task ID** (optional): [Create a task](https://docs.arthur.ai/docs/create-a-task) to route traces to a specific task
|
|
38
|
+
|
|
39
|
+
### Task routing
|
|
40
|
+
|
|
41
|
+
Arthur Engine associates traces with tasks in two ways:
|
|
42
|
+
|
|
43
|
+
- **By service name**: Set `serviceName` in the observability config. Arthur Engine automatically routes traces to the task matching that name, creating it if needed.
|
|
44
|
+
- **By task ID**: Pass a pre-existing `taskId` to the exporter to send traces to a specific task directly.
|
|
45
|
+
|
|
46
|
+
If both are provided, `taskId` takes precedence.
|
|
47
|
+
|
|
48
|
+
### Environment variables
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Required
|
|
52
|
+
ARTHUR_API_KEY=your-api-key
|
|
53
|
+
ARTHUR_BASE_URL=http://localhost:3030
|
|
54
|
+
|
|
55
|
+
# Optional - route traces to a pre-existing task by ID
|
|
56
|
+
ARTHUR_TASK_ID=your-task-id
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Zero-Config Setup
|
|
60
|
+
|
|
61
|
+
With environment variables set, use the exporter with no configuration:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { Mastra } from '@mastra/core'
|
|
65
|
+
import { Observability } from '@mastra/observability'
|
|
66
|
+
import { ArthurExporter } from '@mastra/arthur'
|
|
67
|
+
|
|
68
|
+
export const mastra = new Mastra({
|
|
69
|
+
observability: new Observability({
|
|
70
|
+
configs: {
|
|
71
|
+
arthur: {
|
|
72
|
+
serviceName: 'my-service',
|
|
73
|
+
exporters: [new ArthurExporter()],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Explicit Configuration
|
|
81
|
+
|
|
82
|
+
You can also pass credentials directly (takes precedence over environment variables):
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { Mastra } from '@mastra/core'
|
|
86
|
+
import { Observability } from '@mastra/observability'
|
|
87
|
+
import { ArthurExporter } from '@mastra/arthur'
|
|
88
|
+
|
|
89
|
+
export const mastra = new Mastra({
|
|
90
|
+
observability: new Observability({
|
|
91
|
+
configs: {
|
|
92
|
+
arthur: {
|
|
93
|
+
serviceName: 'my-service',
|
|
94
|
+
exporters: [
|
|
95
|
+
new ArthurExporter({
|
|
96
|
+
apiKey: process.env.ARTHUR_API_KEY!,
|
|
97
|
+
endpoint: process.env.ARTHUR_BASE_URL!,
|
|
98
|
+
taskId: process.env.ARTHUR_TASK_ID,
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Configuration options
|
|
108
|
+
|
|
109
|
+
### Complete Configuration
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
new ArthurExporter({
|
|
113
|
+
// Arthur Configuration
|
|
114
|
+
apiKey: 'your-api-key', // Required
|
|
115
|
+
endpoint: 'http://localhost:3030', // Required
|
|
116
|
+
taskId: 'your-task-id', // Optional
|
|
117
|
+
|
|
118
|
+
// Optional OTLP settings
|
|
119
|
+
headers: {
|
|
120
|
+
'x-custom-header': 'value', // Additional headers for OTLP requests
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
// Debug and performance tuning
|
|
124
|
+
logLevel: 'debug', // Logging: debug | info | warn | error
|
|
125
|
+
batchSize: 512, // Batch size before exporting spans
|
|
126
|
+
timeout: 30000, // Timeout in ms before exporting spans
|
|
127
|
+
|
|
128
|
+
// Custom resource attributes
|
|
129
|
+
resourceAttributes: {
|
|
130
|
+
'deployment.environment': process.env.NODE_ENV,
|
|
131
|
+
'service.version': process.env.APP_VERSION,
|
|
132
|
+
},
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Custom metadata
|
|
137
|
+
|
|
138
|
+
Non-reserved span attributes are serialized into the OpenInference `metadata` payload and surface in Arthur. You can add them via `tracingOptions.metadata`:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
await agent.generate(input, {
|
|
142
|
+
tracingOptions: {
|
|
143
|
+
metadata: {
|
|
144
|
+
companyId: 'acme-co',
|
|
145
|
+
tier: 'enterprise',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Reserved fields such as `input`, `output`, `sessionId`, thread/user IDs, and OpenInference IDs are excluded automatically.
|
|
152
|
+
|
|
153
|
+
## OpenInference semantic conventions
|
|
154
|
+
|
|
155
|
+
This exporter implements the [OpenInference Semantic Conventions](https://github.com/Arize-ai/openinference/tree/main/spec) for generative AI applications, providing standardized trace structure across different observability platforms.
|
|
156
|
+
|
|
157
|
+
## Related
|
|
158
|
+
|
|
159
|
+
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
160
|
+
- [ArthurExporter reference](https://mastra.ai/reference/observability/tracing/exporters/arthur)
|
|
161
|
+
- [Arthur Engine documentation](https://docs.arthur.ai/)
|
|
162
|
+
- [Arthur Engine repository](https://github.com/arthur-ai/arthur-engine)
|
|
163
|
+
- [OpenInference Specification](https://github.com/Arize-ai/openinference/tree/main/spec)
|
|
@@ -1,23 +1,100 @@
|
|
|
1
1
|
# Cloud exporter
|
|
2
2
|
|
|
3
|
-
The `CloudExporter` sends traces
|
|
3
|
+
The `CloudExporter` sends traces, logs, metrics, scores, and feedback to the Mastra platform. Use it to route observability data from any Mastra app to a hosted project in the Mastra platform.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **Self-hosted or standalone apps:** If you host your Mastra application on your own infrastructure (not on Mastra Platform), you still need a deployed Studio project to view traces, logs, and metrics. `CloudExporter` sends data to a Studio project, so one must exist before you can use it.
|
|
6
|
+
>
|
|
7
|
+
> 1. [Create a Mastra project](https://mastra.ai/guides/getting-started/quickstart) if you don't have one yet.
|
|
8
|
+
> 2. [Deploy Studio](https://mastra.ai/docs/studio/deployment) to the Mastra platform with `mastra studio deploy`.
|
|
9
|
+
> 3. Follow the [quickstart steps below](#quickstart) to create an access token and find your project ID.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
## Version compatibility
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
- Use `CloudExporter` with `@mastra/observability@1.8.0` or later.
|
|
14
|
+
- If you use `@mastra/observability@1.8.0` through `1.9.1`, set `MASTRA_CLOUD_TRACES_ENDPOINT=https://observability.mastra.ai` in addition to `MASTRA_CLOUD_ACCESS_TOKEN` and `MASTRA_PROJECT_ID`.
|
|
15
|
+
- Starting in `@mastra/observability@1.9.2`, `CloudExporter` defaults to `https://observability.mastra.ai`, so `MASTRA_CLOUD_TRACES_ENDPOINT` is only required when you want to send telemetry to a different collector.
|
|
16
|
+
|
|
17
|
+
## Quickstart
|
|
18
|
+
|
|
19
|
+
To connect `CloudExporter`, create an access token, find the destination `projectId`, and add the exporter to your observability config.
|
|
20
|
+
|
|
21
|
+
### 1. Create an access token
|
|
22
|
+
|
|
23
|
+
Run the following command:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
mastra auth tokens create exporter-token
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This command prints a token secret that you can use as `MASTRA_CLOUD_ACCESS_TOKEN`.
|
|
30
|
+
|
|
31
|
+
If you already have an access token, copy the **Observability** value from the Mastra platform instead. You can find it in either of these places:
|
|
32
|
+
|
|
33
|
+
- On the **Projects** page, open the project list and find the **Observability** row on the project card.
|
|
34
|
+
- On the project **Overview** page, find the **Observability** row directly below the deployment URL.
|
|
35
|
+
|
|
36
|
+
Set the token as an environment variable:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
MASTRA_CLOUD_ACCESS_TOKEN=<your-cloud-access-token>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Find your `projectId`
|
|
43
|
+
|
|
44
|
+
Run the following command:
|
|
13
45
|
|
|
14
46
|
```bash
|
|
15
|
-
|
|
47
|
+
mastra studio deploy list
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The output looks similar to this:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
✅ <your-project-name> (<your-project-id>)
|
|
54
|
+
Latest: 00000000-0000-0000-0000-000000000000 — running
|
|
55
|
+
URL: https://260407.studio.mastra.cloud
|
|
16
56
|
```
|
|
17
57
|
|
|
18
|
-
|
|
58
|
+
In this output, the value in parentheses is the `projectId`:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
<your-project-id>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Set it as an environment variable:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
MASTRA_PROJECT_ID=<your-project-id>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Set your environment variables
|
|
71
|
+
|
|
72
|
+
Set both values in your environment so `CloudExporter` can authenticate and route telemetry to the correct project:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
MASTRA_CLOUD_ACCESS_TOKEN=<your-cloud-access-token>
|
|
76
|
+
MASTRA_PROJECT_ID=<your-project-id>
|
|
77
|
+
```
|
|
19
78
|
|
|
20
|
-
|
|
79
|
+
If you use `@mastra/observability@1.8.0` through `1.9.1`, also set the Mastra platform collector explicitly:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
MASTRA_CLOUD_TRACES_ENDPOINT=https://observability.mastra.ai
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If you want to send telemetry somewhere other than Mastra platform, set `MASTRA_CLOUD_TRACES_ENDPOINT` as well. Pass either a base origin or a full traces publish URL ending in `/spans/publish`.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
MASTRA_CLOUD_TRACES_ENDPOINT=https://collector.example.com
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
When you pass a base origin, `CloudExporter` derives the matching publish URLs for traces, logs, metrics, scores, and feedback automatically.
|
|
92
|
+
|
|
93
|
+
### 4. Enable `CloudExporter`
|
|
94
|
+
|
|
95
|
+
The following example demonstrates how to add `CloudExporter` to your observability config:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
21
98
|
import { Mastra } from '@mastra/core'
|
|
22
99
|
import { Observability, CloudExporter } from '@mastra/observability'
|
|
23
100
|
|
|
@@ -25,21 +102,35 @@ export const mastra = new Mastra({
|
|
|
25
102
|
observability: new Observability({
|
|
26
103
|
configs: {
|
|
27
104
|
production: {
|
|
28
|
-
serviceName: '
|
|
29
|
-
exporters: [
|
|
30
|
-
new CloudExporter(), // Uses MASTRA_CLOUD_ACCESS_TOKEN env var
|
|
31
|
-
],
|
|
105
|
+
serviceName: 'api-server',
|
|
106
|
+
exporters: [new CloudExporter()],
|
|
32
107
|
},
|
|
33
108
|
},
|
|
34
109
|
}),
|
|
35
110
|
})
|
|
36
111
|
```
|
|
37
112
|
|
|
38
|
-
|
|
113
|
+
Set `serviceName` on the observability config, not on `CloudExporter` itself.
|
|
114
|
+
|
|
115
|
+
Use a stable `serviceName` value. In Studio, traces can be filtered by **Deployments → Service Name**, so a consistent name makes traces easier to find.
|
|
39
116
|
|
|
40
|
-
|
|
117
|
+
Visit [Observability configuration reference](https://mastra.ai/reference/observability/tracing/configuration) for the full observability config shape.
|
|
118
|
+
|
|
119
|
+
If you prefer, rely entirely on environment variables:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
new CloudExporter()
|
|
123
|
+
```
|
|
41
124
|
|
|
42
|
-
|
|
125
|
+
With `MASTRA_CLOUD_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` set, `CloudExporter` sends data to the Mastra platform project you configured. If you also set `MASTRA_CLOUD_TRACES_ENDPOINT`, it sends data to that collector instead.
|
|
126
|
+
|
|
127
|
+
> **Note:** Visit [CloudExporter reference](https://mastra.ai/reference/observability/tracing/exporters/cloud-exporter) for the full list of configuration options.
|
|
128
|
+
|
|
129
|
+
## Recommended configuration
|
|
130
|
+
|
|
131
|
+
Include `DefaultExporter` if you also want to inspect local traces in Studio or persist observability data to your configured storage.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
43
134
|
import { Mastra } from '@mastra/core'
|
|
44
135
|
import {
|
|
45
136
|
Observability,
|
|
@@ -53,10 +144,7 @@ export const mastra = new Mastra({
|
|
|
53
144
|
configs: {
|
|
54
145
|
default: {
|
|
55
146
|
serviceName: 'mastra',
|
|
56
|
-
exporters: [
|
|
57
|
-
new DefaultExporter(),
|
|
58
|
-
new CloudExporter(), // Sends traces to Mastra Cloud (requires MASTRA_CLOUD_ACCESS_TOKEN)
|
|
59
|
-
],
|
|
147
|
+
exporters: [new DefaultExporter(), new CloudExporter()],
|
|
60
148
|
spanOutputProcessors: [new SensitiveDataFilter()],
|
|
61
149
|
},
|
|
62
150
|
},
|
|
@@ -64,64 +152,48 @@ export const mastra = new Mastra({
|
|
|
64
152
|
})
|
|
65
153
|
```
|
|
66
154
|
|
|
67
|
-
|
|
155
|
+
## Complete configuration
|
|
68
156
|
|
|
69
|
-
|
|
70
|
-
new CloudExporter({
|
|
71
|
-
// Optional - defaults to env var
|
|
72
|
-
accessToken: process.env.MASTRA_CLOUD_ACCESS_TOKEN,
|
|
157
|
+
`CloudExporter` defaults to Mastra platform. If you want to send telemetry to a different collector, set `MASTRA_CLOUD_TRACES_ENDPOINT` in your environment or pass `endpoint` in code.
|
|
73
158
|
|
|
74
|
-
|
|
75
|
-
|
|
159
|
+
```bash
|
|
160
|
+
MASTRA_CLOUD_TRACES_ENDPOINT=https://collector.example.com
|
|
161
|
+
```
|
|
76
162
|
|
|
77
|
-
|
|
78
|
-
maxBatchSize: 1000, // Max spans per batch
|
|
79
|
-
maxBatchWaitMs: 5000, // Max wait before sending batch
|
|
163
|
+
The following example demonstrates how to override the collector endpoint and batching behavior in code:
|
|
80
164
|
|
|
81
|
-
|
|
82
|
-
|
|
165
|
+
```ts
|
|
166
|
+
new CloudExporter({
|
|
167
|
+
endpoint: 'https://collector.example.com',
|
|
168
|
+
maxBatchSize: 1000,
|
|
169
|
+
maxBatchWaitMs: 5000,
|
|
170
|
+
logLevel: 'info',
|
|
83
171
|
})
|
|
84
172
|
```
|
|
85
173
|
|
|
86
|
-
## Viewing
|
|
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
|
|
174
|
+
## Viewing data in Mastra Studio
|
|
102
175
|
|
|
103
|
-
|
|
176
|
+
After you enable `CloudExporter`, open your project in [Mastra Studio](https://projects.mastra.ai) to inspect the exported data.
|
|
104
177
|
|
|
105
|
-
|
|
178
|
+
- Open the project you set `MASTRA_PROJECT_ID` to and select **Open Studio**.
|
|
179
|
+
- In Studio, go to **Traces** to inspect agent and workflow traces.
|
|
180
|
+
- Open the filter menu and use **Deployments → Service Name** to isolate traces from a specific app or deployment.
|
|
181
|
+
- Use the **Logs** page in the project dashboard to inspect exported logs.
|
|
106
182
|
|
|
107
|
-
|
|
108
|
-
- **Span Details** - Inputs, outputs, metadata
|
|
109
|
-
- **Performance Metrics** - Latency, token usage
|
|
110
|
-
- **Team Collaboration** - Share trace links
|
|
183
|
+
When you deploy with Mastra Studio, set **Deployment → Service Name** to a stable value and keep it aligned with the `serviceName` in your observability config. This makes traces easier to filter in Studio through **Deployments → Service Name** when multiple services or deployments send data to the same project.
|
|
111
184
|
|
|
112
185
|
## Performance
|
|
113
186
|
|
|
114
|
-
> **Info:** CloudExporter uses
|
|
187
|
+
> **Info:** CloudExporter uses batching to optimize network usage. Events are buffered and sent in batches, reducing overhead while maintaining near real-time visibility.
|
|
115
188
|
|
|
116
|
-
### Batching
|
|
189
|
+
### Batching behavior
|
|
117
190
|
|
|
118
|
-
-
|
|
119
|
-
- Batches are sent when full or after `maxBatchWaitMs` (default: 5 seconds)
|
|
120
|
-
- Failed batches are retried with exponential backoff
|
|
121
|
-
-
|
|
191
|
+
- Events are batched up to `maxBatchSize` (default: 1000).
|
|
192
|
+
- Batches are sent when full or after `maxBatchWaitMs` (default: 5 seconds).
|
|
193
|
+
- Failed batches are retried with exponential backoff.
|
|
194
|
+
- The exporter degrades gracefully if Mastra Studio is unreachable.
|
|
122
195
|
|
|
123
196
|
## Related
|
|
124
197
|
|
|
125
198
|
- [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)
|
|
199
|
+
- [DefaultExporter](https://mastra.ai/docs/observability/tracing/exporters/default)
|
|
@@ -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
|
| -------------------- | ------------ |
|