LangSmithExporter
Sends AI tracing data to LangSmith for observability.
Constructor
new LangSmithExporter(config: LangSmithExporterConfig)
LangSmithExporterConfig
interface LangSmithExporterConfig extends ClientConfig {
logLevel?: "debug" | "info" | "warn" | "error";
client?: Client;
}
Methods
exportEvent
async exportEvent(event: AITracingEvent): 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
| AI Span Type | LangSmith Type |
|---|---|
LLM_GENERATION | llm |
LLM_CHUNK | llm |
TOOL_CALL | tool |
MCP_TOOL_CALL | tool |
| All others | chain |