LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangSmith
  • Client
  • Run Trees
  • Traceable
  • Evaluation
  • Schemas
  • Langchain
  • Jest
  • Vitest
  • Wrappers
  • Anonymizer
  • Jestlike
  • Vercel
  • Anthropic
  • Sandbox
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangSmith
ClientRun TreesTraceableEvaluationSchemasLangchainJestVitestWrappersAnonymizerJestlikeVercelAnthropicSandbox
Language
Theme
JavaScriptlangsmithtraceabletraceable
Function●Since v0.1

traceable

Higher-order function that takes function as input and returns a "TraceableFunction" - a wrapped version of the input that automatically handles tracing. If the returned traceable function calls any traceable functions, those are automatically traced as well.

The returned TraceableFunction can accept a run tree or run tree config as its first argument. If omitted, it will default to the caller's run tree, or will be treated as a root run.

Copy
traceable<Func extends (
  args: any[]) => any>(wrappedFunc: Func, config: TraceableConfig<Func>
): TraceableFunction<Func>

Used in Docs

  • Access the current run (span) within a traced function
  • Add metadata and tags to traces
  • Conditional tracing
  • Configure threads
  • Cost tracking
(12 more not shown)

Parameters

NameTypeDescription
wrappedFunc*Func

Targeted function to be traced

configTraceableConfig<Func>

Additional metadata such as name, tags or providing a custom LangSmith client instance

View source on GitHub