> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # Laminar exporter [Laminar](https://laminar.sh/) 是一個開源、以 OpenTelemetry 為基礎的 AI Agent 可觀測性平台。只需在 `Observability` 配置中接入一個 `MastraExporter`,即可追蹤、偵錯及監察每次 Mastra Agent 執行、模型步驟、Tool 呼叫及子 Agent。 ## 安裝 **npm**: ```bash npm install @lmnr-ai/lmnr ``` **pnpm**: ```bash pnpm add @lmnr-ai/lmnr ``` **Yarn**: ```bash yarn add @lmnr-ai/lmnr ``` **Bun**: ```bash bun add @lmnr-ai/lmnr ``` ## 配置 ### 先決條件 1. **Laminar 項目**:在 Laminar 建立或選擇一個項目 2. **項目 API 金鑰**:從 Laminar Project Settings 複製 3. **環境變數**:設定你的憑證 ```bash # Required LMNR_PROJECT_API_KEY=lmnr_... # Optional LMNR_BASE_URL=https://api.lmnr.ai ``` ### 零配置設定 設定環境變數後,無需提供任何配置即可使用 exporter: ```typescript 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()], }, }, }), }) ``` ### 明確配置 你亦可直接傳入憑證(其優先級高於環境變數): ```typescript 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 }), ], }, }, }), }) ``` > **備註:** 如需了解進階用法,包括完整的 `MastraExporter` 選項及多 Agent Trace 範例,請參閱 [Laminar 的 Mastra 整合指南](https://laminar.sh/docs/tracing/integrations/mastra)。 Mastra 亦在 `@mastra/laminar` 中提供獨立的 [`LaminarExporter`](https://mastra.zisheng.pro/zh-HK/reference/observability/tracing/exporters/laminar),透過 OTLP/HTTP 傳送 span。它無法繼承有效的 OTel context,也不會將 Mastra span 完整映射至 Laminar 的原生格式。因此,如要使用 `observe()` wrapper、多 Agent root span,以及在 Laminar 中準確呈現資料,請使用上方的 `@lmnr-ai/lmnr` 整合。 ## 相關內容 - [Tracing 概覽](https://mastra.zisheng.pro/zh-HK/docs/observability/tracing/overview) - [Laminar 文件](https://laminar.sh/docs)