Home / Function/ _get_trace_callbacks() — langchain Function Reference

_get_trace_callbacks() — langchain Function Reference

Architecture documentation for the _get_trace_callbacks() function in context.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f1271626_ef97_53db_898a_b2873112b894["_get_trace_callbacks()"]
  b631c948_af4b_1ae8_be2d_c334ff40ecef["context.py"]
  f1271626_ef97_53db_898a_b2873112b894 -->|defined in| b631c948_af4b_1ae8_be2d_c334ff40ecef
  73d7cc8c_bdec_b9fe_bab5_fb304aec22a5["_tracing_v2_is_enabled()"]
  f1271626_ef97_53db_898a_b2873112b894 -->|calls| 73d7cc8c_bdec_b9fe_bab5_fb304aec22a5
  71c76bc1_1f57_b122_9d67_fd96e58f068a["_get_tracer_project()"]
  f1271626_ef97_53db_898a_b2873112b894 -->|calls| 71c76bc1_1f57_b122_9d67_fd96e58f068a
  style f1271626_ef97_53db_898a_b2873112b894 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tracers/context.py lines 105–129

def _get_trace_callbacks(
    project_name: str | None = None,
    example_id: str | UUID | None = None,
    callback_manager: CallbackManager | AsyncCallbackManager | None = None,
) -> Callbacks:
    if _tracing_v2_is_enabled():
        project_name_ = project_name or _get_tracer_project()
        tracer = tracing_v2_callback_var.get() or LangChainTracer(
            project_name=project_name_,
            example_id=example_id,
        )
        if callback_manager is None:
            cb = cast("Callbacks", [tracer])
        else:
            if not any(
                isinstance(handler, LangChainTracer)
                for handler in callback_manager.handlers
            ):
                callback_manager.add_handler(tracer)
                # If it already has a LangChainTracer, we don't need to add another one.
                # this would likely mess up the trace hierarchy.
            cb = callback_manager
    else:
        cb = None
    return cb

Domain

Subdomains

Frequently Asked Questions

What does _get_trace_callbacks() do?
_get_trace_callbacks() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/context.py.
Where is _get_trace_callbacks() defined?
_get_trace_callbacks() is defined in libs/core/langchain_core/tracers/context.py at line 105.
What does _get_trace_callbacks() call?
_get_trace_callbacks() calls 2 function(s): _get_tracer_project, _tracing_v2_is_enabled.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free