LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmithrun_helperstrace
Class●Since v0.0

trace

Manage a LangSmith run in context.

This class can be used as both a synchronous and asynchronous context manager.

Copy
trace(
  self,
  name: str,
  run_type: ls_client.RUN_TYPE_T = 'chain',
  *,
  inputs: Optional

Used in Docs

  • Log user feedback using the SDK
  • Messages view integrations

Constructors

Attributes

View source on GitHub
[
dict
]
=
None
,
extra
:
Optional
[
dict
]
=
None
,
project_name
:
Optional
[
str
]
=
None
,
parent
:
Optional
[
Union
[
run_trees
.
RunTree
,
str
,
Mapping
,
Literal
[
'ignore'
]
]
]
=
None
,
tags
:
Optional
[
list
[
str
]
]
=
None
,
metadata
:
Optional
[
Mapping
[
str
,
Any
]
]
=
None
,
client
:
Optional
[
ls_client
.
Client
]
=
None
,
run_id
:
Optional
[
ls_client
.
ID_TYPE
]
=
None
,
reference_example_id
:
Optional
[
ls_client
.
ID_TYPE
]
=
None
,
exceptions_to_handle
:
Optional
[
tuple
[
type
[
BaseException
]
,
.
.
.
]
]
=
None
,
attachments
:
Optional
[
schemas
.
Attachments
]
=
None
,
**
kwargs
:
Any
=
{
}
)

Parameters

NameTypeDescription
name*str

Name of the run.

run_typels_client.RUN_TYPE_T
Default:'chain'

Type of run (e.g., 'chain', 'llm', 'tool').

inputsOptional[dict]
Default:None
project_nameOptional[str]
Default:None
parentOptional[Union[run_trees.RunTree, str, Mapping, Literal['ignore']]]
Default:None
tagsOptional[list[str]]
Default:None
metadataOptional[Mapping[str, Any]]
Default:None
clientOptional[ls_client.Client]
Default:None
run_idOptional[ls_client.ID_TYPE]
Default:None
reference_example_idOptional[ls_client.ID_TYPE]
Default:None
exceptions_to_handleOptional[tuple[type[BaseException], ...]]
Default:None
extraOptional[dict]
Default:None
constructor
__init__
NameType
namestr
run_typels_client.RUN_TYPE_T
inputsOptional[dict]
extraOptional[dict]
project_nameOptional[str]
parentOptional[Union[run_trees.RunTree, str, Mapping, Literal['ignore']]]
tagsOptional[list[str]]
metadataOptional[Mapping[str, Any]]
clientOptional[ls_client.Client]
run_idOptional[ls_client.ID_TYPE]
reference_example_idOptional[ls_client.ID_TYPE]
exceptions_to_handleOptional[tuple[type[BaseException], ...]]
attachmentsOptional[schemas.Attachments]
attribute
name: name
attribute
run_type: run_type
attribute
inputs: inputs
attribute
attachments: attachments
attribute
extra: extra
attribute
project_name: project_name
attribute
parent: parent
attribute
run_tree
attribute
tags: tags
attribute
metadata: metadata
attribute
client: client
attribute
run_id: run_id
attribute
reference_example_id: reference_example_id
attribute
exceptions_to_handle: exceptions_to_handle
attribute
new_run: Optional[run_trees.RunTree]
attribute
old_ctx: Optional[dict]

Initial input data for the run.

Project name to associate the run with.

Parent run.

Can be a RunTree, dotted order string, or tracing headers.

List of tags for the run.

Additional metadata for the run.

LangSmith client for custom settings.

Preset identifier for the run.

Associates run with a dataset example.

Only for root runs in evaluation.

Exception types to ignore.

Extra data to send to LangSmith.

Use 'metadata' instead.