🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@mastra/datadog

Package Overview
Dependencies
Maintainers
1
Versions
356
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons
This package has malicious versions linked to the ongoing "Mastra AI framework compromise" supply chain attack.

Affected versions:

1.2.5
View campaign page

@mastra/datadog

Datadog LLM Observability exporter for Mastra - exports tracing data to Datadog's LLM Observability product

unpublished
Source
npmnpm
Version
1.2.5
Version published
Weekly downloads
110K
25.16%
Maintainers
1
Weekly downloads
 
Created
Source

@mastra/datadog

Datadog LLM Observability exporter for Mastra. Exports observability data to Datadog's LLM Observability product.

Installation

pnpm add @mastra/datadog

Requirements

  • Node.js >=22.13.0 (Node.js 22.x recommended; dd-trace native modules ship prebuilt binaries for this ABI)
  • Datadog account with LLM Observability enabled
  • Datadog API key (available in your Datadog account settings)

Usage

Basic Setup

import { Mastra } from '@mastra/core';
import { DatadogExporter } from '@mastra/datadog';

const datadog = new DatadogExporter({
  mlApp: 'my-llm-app',
  apiKey: process.env.DD_API_KEY,
});

const mastra = new Mastra({
  observability: {
    configs: {
      default: {
        serviceName: 'my-service',
        exporters: [datadog],
      },
    },
  },
});

With Local Datadog Agent (Optional)

If you have a Datadog Agent running locally, you can use agent mode instead:

const datadog = new DatadogExporter({
  mlApp: 'my-llm-app',
  agentless: false, // Use local Datadog Agent instead of direct HTTPS
  env: 'production',
});

Configuration Options

OptionDescriptionDefault
apiKeyDatadog API key (required)DD_API_KEY env var
mlAppML application name for grouping traces (required)DD_LLMOBS_ML_APP env var
siteDatadog site (e.g., 'datadoghq.com', 'datadoghq.eu')DD_SITE or 'datadoghq.com'
agentlessUse direct HTTPS intake (no local agent required)true
serviceService name for the applicationUses mlApp value
envEnvironment name (e.g., 'production', 'staging')DD_ENV env var
integrationsEnabledEnable dd-trace automatic integrationsfalse

Note that the site is also used to specify non-default regions, e.g. us3.datadoghq.com instead of us1.datadoghq.com.

Environment Variables

The exporter reads configuration from environment variables:

  • DD_API_KEY - Datadog API key (required)
  • DD_LLMOBS_ML_APP - ML application name
  • DD_SITE - Datadog site
  • DD_ENV - Environment name
  • DD_LLMOBS_AGENTLESS_ENABLED - Set to 'false' or '0' to use local Datadog Agent

Span Type Mapping

Mastra span types are mapped to Datadog LLMObs span kinds:

Mastra SpanTypeDatadog Kind
AGENT_RUNagent
MODEL_GENERATIONworkflow
MODEL_STEPllm
TOOL_CALLtool
MCP_TOOL_CALLtool
WORKFLOW_RUNworkflow
All other typestask

All unmapped span types (including MODEL_CHUNK, GENERIC, etc., and future span types) automatically default to task.

Features

  • Completion-only pattern: Spans are emitted at completion for efficient tracing
  • Message formatting: LLM inputs/outputs formatted as message arrays
  • Metadata as tags: Span metadata is flattened into searchable Datadog tags
  • Error tracking: Error spans include error tags with message, ID, and category
  • Parent/child hierarchy: Spans are emitted parent-first to preserve trace trees in Datadog

Troubleshooting

Native module ABI errors

If you see errors like No native build was found for runtime=node abi=137:

These are non-blocking warnings. The dd-trace native modules (@datadog/native-metrics, etc.) are optional and provide performance monitoring features. Core tracing works without them.

Options:

  • Use Node.js 22.x - Prebuilt binaries for dd-trace native modules target Node.js 22 (ABI 127/131). Newer Node.js versions have different ABIs.
  • Ignore the errors - These are warnings, not fatal errors. LLM observability tracing functions normally without native modules.

Bundler configuration

When using bundlers, mark dd-trace and native modules as external:

// src/mastra/index.ts
export const mastra = new Mastra({
  bundler: {
    externals: [
      'dd-trace',
      '@datadog/native-metrics',
      '@datadog/native-appsec',
      '@datadog/native-iast-taint-tracking',
      '@datadog/pprof',
    ],
  },
});

License

Apache-2.0

FAQs

Package last updated on 17 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts