LangSmithExporter
Sends Tracing data to LangSmith for observability.
ConstructorDirect link to Constructor
new LangSmithExporter(config: LangSmithExporterConfig)
LangSmithExporterConfigDirect link to LangSmithExporterConfig
interface LangSmithExporterConfig extends ClientConfig, BaseExporterConfig {
client?: Client;
projectName?: string;
}
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.
MethodsDirect link to Methods
exportTracingEventDirect link to exportTracingEvent
async exportTracingEvent(event: TracingEvent): Promise<void>
Exports a tracing event to LangSmith.
shutdownDirect link to shutdown
async shutdown(): Promise<void>
Ends all active spans and clears the trace map.
UsageDirect link to Usage
import { LangSmithExporter } from "@mastra/langsmith";
const exporter = new LangSmithExporter({
apiKey: process.env.LANGSMITH_API_KEY,
projectName: "my-project", // Optional: specify which project to send traces to
apiUrl: "https://api.smith.langchain.com",
logLevel: "info",
});
Environment VariablesDirect link to Environment Variables
| Variable | Description |
|---|---|
LANGSMITH_API_KEY | Your LangSmith API key |
LANGCHAIN_PROJECT | Default project name for traces (used if projectName not specified) |
LANGSMITH_BASE_URL | API URL for self-hosted instances |
Span Type MappingDirect link to Span Type Mapping
| Span Type | LangSmith Type |
|---|---|
MODEL_GENERATION | llm |
MODEL_CHUNK | llm |
TOOL_CALL | tool |
MCP_TOOL_CALL | tool |
| All others | chain |