tracing_v2_enabled#

langchain_core.tracers.context.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][source]#

Instruct LangChain to log all runs in context to LangSmith.

Parameters:
  • project_name (str, optional) – The name of the project. Defaults to β€œdefault”.

  • example_id (str or UUID, optional) – The ID of the example. Defaults to None.

  • tags (List[str], optional) – The tags to add to the run. Defaults to None.

  • client (LangSmithClient, optional) – The client of the langsmith. Defaults to None.

Yields:

LangChainTracer – The LangChain tracer.

Return type:

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()

Examples using tracing_v2_enabled