Skip to content

Commit

Permalink
[Core] Logging: Suppress missing parent warning (#23363)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Jun 25, 2024
1 parent 730c551 commit 8955bc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libs/core/langchain_core/tracers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class _TracerCore(ABC):
This class provides common methods, and reusable methods for tracers.
"""

log_missing_parent: bool = True

def __init__(
self,
*,
Expand Down Expand Up @@ -118,10 +120,11 @@ def _start_trace(self, run: Run) -> Union[None, Coroutine[Any, Any, None]]: # t
if parent_run := self.run_map.get(str(run.parent_run_id)):
self._add_child_run(parent_run, run)
else:
logger.warning(
f"Parent run {run.parent_run_id} not found for run {run.id}."
" Treating as a root run."
)
if self.log_missing_parent:
logger.warning(
f"Parent run {run.parent_run_id} not found for run {run.id}."
" Treating as a root run."
)
run.parent_run_id = None
run.trace_id = run.id
run.dotted_order = current_dotted_order
Expand Down
4 changes: 4 additions & 0 deletions libs/core/langchain_core/tracers/root_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
class RootListenersTracer(BaseTracer):
"""Tracer that calls listeners on run start, end, and error."""

log_missing_parent = False

def __init__(
self,
*,
Expand Down Expand Up @@ -63,6 +65,8 @@ def _on_run_update(self, run: Run) -> None:
class AsyncRootListenersTracer(AsyncBaseTracer):
"""Async Tracer that calls listeners on run start, end, and error."""

log_missing_parent = False

def __init__(
self,
*,
Expand Down

0 comments on commit 8955bc1

Please sign in to comment.