tracing_context#

langsmith.run_helpers.tracing_context(*, project_name: str | None = None, tags: List[str] | None = None, metadata: Dict[str, Any] | None = None, parent: RunTree | str | Mapping | None = None, enabled: bool | Literal['local'] | None = None, client: Client | None = None, **kwargs: Any) Generator[None, None, None][source]#

Set the tracing context for a block of code.

Parameters:
  • project_name (str | None) – The name of the project to log the run to. Defaults to None.

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

  • metadata (Dict[str, Any] | None) – The metadata to add to the run. Defaults to None.

  • parent (RunTree | str | Mapping | None) – The parent run to use for the context. Can be a Run/RunTree object, request headers (for distributed tracing), or the dotted order string. Defaults to None.

  • client (Client | None) – The client to use for logging the run to LangSmith. Defaults to None,

  • enabled (bool | Literal['local'] | None) – Whether tracing is enabled. Defaults to None, meaning it will use the current context value or environment variables.

  • kwargs (Any) –

Return type:

Generator[None, None, None]