Skip to main content

LangSmithExporter

Sends Tracing data to LangSmith for observability.

Constructor

new LangSmithExporter(config: LangSmithExporterConfig)

LangSmithExporterConfig

interface LangSmithExporterConfig extends ClientConfig, BaseExporterConfig {
client?: Client;
}

Extends both ClientConfig (from LangSmith SDK) and BaseExporterConfig:

  • From BaseExporterConfig: logger?: IMastraLogger, logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'
  • From ClientConfig: apiKey, apiUrl, callerOptions, hideInputs, hideOutputs, etc.

Methods

exportTracingEvent

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

Exports a tracing event to LangSmith.

shutdown

async shutdown(): Promise<void>

Ends all active spans and clears the trace map.

Usage

import { LangSmithExporter } from "@mastra/langsmith";

const exporter = new LangSmithExporter({
apiKey: process.env.LANGSMITH_API_KEY,
apiUrl: "https://api.smith.langchain.com",
logLevel: "info",
});

Span Type Mapping

Span TypeLangSmith Type
MODEL_GENERATIONllm
MODEL_CHUNKllm
TOOL_CALLtool
MCP_TOOL_CALLtool
All otherschain