Skip to main content

LaminarExporter

通过 OTLP/HTTP(protobuf)将跟踪数据发送到 Laminar。

🌐 Sends Tracing data to Laminar via OTLP/HTTP (protobuf).

构造函数
Direct link to 构造函数

🌐 Constructor

new LaminarExporter(config?: LaminarExporterConfig)

LaminarExporterConfig
Direct link to LaminarExporterConfig

interface LaminarExporterConfig extends BaseExporterConfig {
apiKey?: string;
baseUrl?: string;
endpoint?: string;
headers?: Record<string, string>;
realtime?: boolean;
disableBatch?: boolean;
batchSize?: number;
timeoutMillis?: number;
}

扩展自 BaseExporterConfig,包括:

🌐 Extends BaseExporterConfig, which includes:

  • logger?: IMastraLogger - 记录器实例
  • logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error' - 日志级别(默认:INFO)

方法
Direct link to 方法

🌐 Methods

exportTracingEvent
Direct link to exportTracingEvent

async exportTracingEvent(event: TracingEvent): Promise<void>

将跟踪事件导出到 Laminar。

🌐 Exports a tracing event to Laminar.

flush
Direct link to flush

async flush(): Promise<void>

强制将任何缓冲的跨度刷新到 Laminar,而不关闭导出器。在无服务器环境中非常有用,因为你需要确保在运行时终止之前导出跨度。

🌐 Force flushes any buffered spans to Laminar without shutting down the exporter. Useful in serverless environments where you need to ensure spans are exported before the runtime terminates.

shutdown
Direct link to shutdown

async shutdown(): Promise<void>

刷新待处理的数据并关闭导出器。

🌐 Flushes pending data and shuts down the exporter.

用法
Direct link to 用法

🌐 Usage

零配置(使用环境变量)
Direct link to 零配置(使用环境变量)

🌐 Zero-Config (using environment variables)

import { LaminarExporter } from "@mastra/laminar";

// Reads from LMNR_PROJECT_API_KEY, LMNR_BASE_URL, LAMINAR_ENDPOINT
const exporter = new LaminarExporter();

显式配置
Direct link to 显式配置

🌐 Explicit Configuration

import { LaminarExporter } from "@mastra/laminar";

const exporter = new LaminarExporter({
apiKey: process.env.LMNR_PROJECT_API_KEY,
baseUrl: "https://api.lmnr.ai",
realtime: true,
});