collect_runs#

langchain_core.tracers.context.collect_runs() Generator[RunCollectorCallbackHandler, None, None][source]#

Collect all run traces in context.

Yields:

run_collector.RunCollectorCallbackHandler – The run collector callback handler.

Return type:

Generator[RunCollectorCallbackHandler, None, None]

Example

>>> with collect_runs() as runs_cb:
        chain.invoke("foo")
        run_id = runs_cb.traced_runs[0].id