mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 12:01:54 +00:00
fix(core): honor enabled=false
in nested tracing (#31986)
Co-authored-by: Mason Daugherty <mason@langchain.dev> Co-authored-by: Mason Daugherty <github@mdrxy.com>
This commit is contained in:
@@ -8,7 +8,7 @@ from datetime import datetime, timezone
|
||||
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||
from uuid import UUID
|
||||
|
||||
from langsmith import Client
|
||||
from langsmith import Client, get_tracing_context
|
||||
from langsmith import run_trees as rt
|
||||
from langsmith import utils as ls_utils
|
||||
from tenacity import (
|
||||
@@ -113,6 +113,8 @@ class LangChainTracer(BaseTracer):
|
||||
super()._start_trace(run)
|
||||
if run.ls_client is None:
|
||||
run.ls_client = self.client
|
||||
if get_tracing_context().get("enabled") is False:
|
||||
run.extra["__disabled"] = True
|
||||
|
||||
def on_chat_model_start(
|
||||
self,
|
||||
@@ -205,6 +207,8 @@ class LangChainTracer(BaseTracer):
|
||||
|
||||
def _persist_run_single(self, run: Run) -> None:
|
||||
"""Persist a run."""
|
||||
if run.extra.get("__disabled"):
|
||||
return
|
||||
try:
|
||||
run.extra["runtime"] = get_runtime_environment()
|
||||
run.tags = self._get_tags(run)
|
||||
@@ -218,6 +222,8 @@ class LangChainTracer(BaseTracer):
|
||||
|
||||
def _update_run_single(self, run: Run) -> None:
|
||||
"""Update a run."""
|
||||
if run.extra.get("__disabled"):
|
||||
return
|
||||
try:
|
||||
run.patch(exclude_inputs=run.extra.get("inputs_is_truthy", False))
|
||||
except Exception as e:
|
||||
|
Reference in New Issue
Block a user