跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Laminar

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
Installation的直接链接

npm install @lmnr-ai/lmnr

Configuration
Configuration的直接链接

Prerequisites
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
.env
# Required
LMNR_PROJECT_API_KEY=lmnr_...

# Optional
LMNR_BASE_URL=https://api.lmnr.ai

Zero-Config Setup
Zero-Config Setup的直接链接

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

src/mastra/index.ts
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
Explicit Configuration的直接链接

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

src/mastra/index.ts
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
}),
],
},
},
}),
})
备注

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

Mastra also includes a standalone LaminarExporter in @mastra/laminar that sends spans over OTLP/HTTP. It can't inherit an active OTel context and doesn't 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.