/** * LangSmith Exporter for Mastra Tracing * * This exporter sends observability data to LangSmith * Root spans become top-level LangSmith RunTrees (no trace wrapper). * Events are handled as zero-duration RunTrees with matching start/end times. */ import type { AnyExportedSpan, ScoreEvent, SpanErrorInfo } from '@mastra/core/observability'; import { TrackingExporter } from '@mastra/observability'; import type { TraceData, TrackingExporterConfig } from '@mastra/observability'; import type { ClientConfig } from 'langsmith'; import { Client, RunTree } from 'langsmith'; import type { LangSmithMetadataInput } from './helpers.js'; export interface LangSmithExporterConfig extends ClientConfig, TrackingExporterConfig { /** LangSmith client instance */ client?: Client; /** * The name of the LangSmith project to send traces to. * Overrides the LANGCHAIN_PROJECT environment variable. * If neither is set, traces are sent to the "default" project. */ projectName?: string; /** * Maximum number of `spanId → langsmithRunId` mappings to retain for resolving * `onScoreEvent` lookups. Older entries are evicted in LRU order when the cap * is exceeded so long-running processes do not grow unbounded. * Defaults to 10000. */ runIdCacheMaxEntries?: number; } type LangSmithRoot = undefined; type LangSmithSpan = RunTree; type LangSmithEvent = RunTree; type LangSmithMetadata = LangSmithMetadataInput; type LangSmithTraceData = TraceData; export declare class LangSmithExporter extends TrackingExporter { #private; name: string; constructor(config?: LangSmithExporterConfig); /** * Flush pending trace batches to LangSmith. * The LangSmith Client internally batches API calls; this ensures * all queued runs are sent before the process exits or the flush * caller continues. */ protected _flush(): Promise; protected _postShutdown(): Promise; onScoreEvent(event: ScoreEvent): Promise; protected skipBuildRootTask: boolean; protected _buildRoot(_args: { span: AnyExportedSpan; traceData: LangSmithTraceData; }): Promise; protected _buildSpan(args: { span: AnyExportedSpan; traceData: LangSmithTraceData; }): Promise; protected _buildEvent(args: { span: AnyExportedSpan; traceData: LangSmithTraceData; }): Promise; protected _updateSpan(args: { span: AnyExportedSpan; traceData: LangSmithTraceData; }): Promise; protected _finishSpan(args: { span: AnyExportedSpan; traceData: LangSmithTraceData; }): Promise; protected _abortSpan(args: { span: LangSmithSpan; traceData: LangSmithTraceData; reason: SpanErrorInfo; }): Promise; private handleSpanUpdateOrEnd; /** * Find LangSmith vendor metadata by walking up the span hierarchy and merging. * Metadata is merged from ancestors with child values taking precedence over parent values. * * TODO(2.0): Extract shared `findVendorMetadata()` to base TrackingExporter class * and reuse here and in LangfuseExporter.findLangfusePrompt() */ private findLangsmithMetadata; private buildRunTreePayload; } export {}; //# sourceMappingURL=tracing.d.ts.map