collect_runs() — langchain Function Reference
Architecture documentation for the collect_runs() function in context.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 74d4cdfa_4571_6b88_0d77_072961ad25d1["collect_runs()"] b631c948_af4b_1ae8_be2d_c334ff40ecef["context.py"] 74d4cdfa_4571_6b88_0d77_072961ad25d1 -->|defined in| b631c948_af4b_1ae8_be2d_c334ff40ecef style 74d4cdfa_4571_6b88_0d77_072961ad25d1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/tracers/context.py lines 86–102
def collect_runs() -> Generator[RunCollectorCallbackHandler, None, None]:
"""Collect all run traces in context.
Yields:
The run collector callback handler.
Example:
>>> with collect_runs() as runs_cb:
chain.invoke("foo")
run_id = runs_cb.traced_runs[0].id
"""
cb = RunCollectorCallbackHandler()
token = run_collector_var.set(cb)
try:
yield cb
finally:
run_collector_var.reset(token)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does collect_runs() do?
collect_runs() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/context.py.
Where is collect_runs() defined?
collect_runs() is defined in libs/core/langchain_core/tracers/context.py at line 86.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free