Laminar exporter

Trust: ★★★☆☆ (0.90) · 0 validations · developer_reference

Published: 2026-05-10 · Source: crawler_authoritative

Tình huống

Mastra users configuring OpenTelemetry-native observability to trace, debug, and monitor AI agent runs, model steps, tool calls, and sub-agents using Laminar’s observability platform.

Insight

Laminar is an open-source, OpenTelemetry-native observability platform for AI agents. The integration uses the @lmnr-ai/lmnr package which provides a MastraExporter class. Installation supports npm (npm install @lmnr-ai/lmnr), pnpm, yarn, and bun package managers. Prerequisites require creating a Laminar project and obtaining a Project API Key from Laminar Project Settings. Required environment variable: LMNR_PROJECT_API_KEY=lmnr_.... Optional environment variable: LMNR_BASE_URL (defaults to https://api.lmnr.ai). Two setup modes are documented: Zero-Config Setup uses Laminar.initialize() with no arguments (reads from env vars) and configures Observability with laminar config containing serviceName and MastraExporter(). Explicit Configuration passes credentials directly to Laminar.initialize({ projectApiKey, baseUrl }) and MastraExporter({ realtime: process.env.NODE_ENV === 'development' }). The page notes that Mastra also ships a standalone LaminarExporter in @mastra/laminar that sends spans over OTLP/HTTP, but it cannot inherit an active OTel context and does not fully map Mastra spans to Laminar’s native format, so @lmnr-ai/lmnr integration is recommended for observe() wrappers, multi-agent root spans, and accurate Laminar rendering.

Hành động

  1. Install the package: npm install @lmnr-ai/lmnr (or pnpm/yarn/bun equivalent). 2. Set environment variables LMNR_PROJECT_API_KEY with your Laminar project API key (and optionally LMNR_BASE_URL). 3. Import Mastra from @mastra/core, Observability from @mastra/observability, and Laminar, MastraExporter from @lmnr-ai/lmnr. 4. Call Laminar.initialize() with optional credentials object. 5. Configure new Observability({ configs: { laminar: { serviceName: 'my-service', exporters: [new MastraExporter({ realtime: boolean })] } } }). 6. Pass the Observability instance to your Mastra config.

Kết quả

Traces, debug sessions, and monitoring data from Mastra agent runs, model steps, tool calls, and sub-agents are exported to Laminar’s observability platform via OpenTelemetry.

Điều kiện áp dụng

Requires @lmnr-ai/lmnr package. For full feature support (observe() wrappers, multi-agent root spans, accurate Laminar rendering), use @lmnr-ai/lmnr instead of the standalone @mastra/laminar exporter.


Nội dung gốc (Original)

Laminar exporter

Laminar is an open-source, OpenTelemetry-native observability platform for AI agents. Trace, debug, and monitor every Mastra agent run, model step, tool call, and sub-agent with a single MastraExporter wired into your Observability config.

Installation

npm:

npm install @lmnr-ai/lmnr

pnpm:

pnpm add @lmnr-ai/lmnr

Yarn:

yarn add @lmnr-ai/lmnr

Bun:

bun add @lmnr-ai/lmnr

Configuration

Prerequisites

  1. Laminar Project: Create/select a project in Laminar
  2. Project API Key: Copy from Laminar Project Settings
  3. Environment Variables: Set your credentials
# Required
LMNR_PROJECT_API_KEY=lmnr_...
 
# Optional
LMNR_BASE_URL=https://api.lmnr.ai

Zero-Config Setup

With environment variables set, use the exporter with no configuration:

import { Mastra } from '@mastra/core'
import { Observability } from '@mastra/observability'
import { Laminar, MastraExporter } from '@lmnr-ai/lmnr'
 
Laminar.initialize()
 
export const mastra = new Mastra({
  observability: new Observability({
    configs: {
      laminar: {
        serviceName: 'my-service',
        exporters: [new MastraExporter()],
      },
    },
  }),
})

Explicit Configuration

You can also pass credentials directly (takes precedence over environment variables):

import { Mastra } from '@mastra/core'
import { Observability } from '@mastra/observability'
import { Laminar, MastraExporter } from '@lmnr-ai/lmnr'
 
Laminar.initialize({
  projectApiKey: process.env.LMNR_PROJECT_API_KEY!,
  baseUrl: process.env.LMNR_BASE_URL, // Optional
  // ...other options
})
 
export const mastra = new Mastra({
  observability: new Observability({
    configs: {
      laminar: {
        serviceName: 'my-service',
        exporters: [
          new MastraExporter({
            realtime: process.env.NODE_ENV === 'development', // Optional
          }),
        ],
      },
    },
  }),
})

Note: For advanced usage, including the full MastraExporter options and multi-agent trace examples, see Laminar’s Mastra integration guide.

Mastra also ships a standalone LaminarExporter in @mastra/laminar that sends spans over OTLP/HTTP. It cannot inherit an active OTel context and does not fully map Mastra spans to Laminar’s native format, so use the @lmnr-ai/lmnr integration above for observe() wrappers, multi-agent root spans, and accurate Laminar rendering.

Liên kết

Xem thêm: