Home / Function/ tracing_v2_enabled() — langchain Function Reference

tracing_v2_enabled() — langchain Function Reference

Architecture documentation for the tracing_v2_enabled() function in context.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8c0c78ba_8cb6_63b5_b4cb_4e1cd6dbf5f8["tracing_v2_enabled()"]
  b631c948_af4b_1ae8_be2d_c334ff40ecef["context.py"]
  8c0c78ba_8cb6_63b5_b4cb_4e1cd6dbf5f8 -->|defined in| b631c948_af4b_1ae8_be2d_c334ff40ecef
  style 8c0c78ba_8cb6_63b5_b4cb_4e1cd6dbf5f8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tracers/context.py lines 40–82

def 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]:
    """Instruct LangChain to log all runs in context to LangSmith.

    Args:
        project_name: The name of the project.

            Defaults to `'default'`.
        example_id: The ID of the example.
        tags: The tags to add to the run.
        client: The client of the langsmith.

    Yields:
        The LangChain tracer.

    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()
    """
    if isinstance(example_id, str):
        example_id = UUID(example_id)
    cb = LangChainTracer(
        example_id=example_id,
        project_name=project_name,
        tags=tags,
        client=client,
    )
    token = tracing_v2_callback_var.set(cb)
    try:
        yield cb
    finally:
        tracing_v2_callback_var.reset(token)

Domain

Subdomains

Frequently Asked Questions

What does tracing_v2_enabled() do?
tracing_v2_enabled() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/context.py.
Where is tracing_v2_enabled() defined?
tracing_v2_enabled() is defined in libs/core/langchain_core/tracers/context.py at line 40.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free