LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coretracerscontexttracing_v2_enabled
    Function●Since v0.1

    tracing_v2_enabled

    Instruct LangChain to log all runs in context to LangSmith.

    Copy
    tracing_v2_enabled(
      project_name: str | None = None,
      *,
      example_id: str | UUID | None = None,
      tags: list[str] | None = None,
      client: LangSmithClient | None = None
    ) -> Generator[LangChainTracer, None, None]

    Example:

    with tracing_v2_enabled(): ... # LangChain code will automatically be traced

    You can use this to fetch the LangSmith run URL:

    with tracing_v2_enabled() as cb: ... chain.invoke("foo") ... run_url = cb.get_run_url()

    Parameters

    NameTypeDescription
    project_namestr | None
    Default:None

    The name of the project.

    Defaults to 'default'.

    example_idstr | UUID | None
    Default:None

    The ID of the example.

    tagslist[str] | None
    Default:None

    The tags to add to the run.

    clientLangSmithClient | None
    Default:None

    The client of the langsmith.

    View source on GitHub