mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-17 10:13:29 +00:00
[Core] Logging: Suppress missing parent warning (#23363)
This commit is contained in:
parent
730c551819
commit
8955bc1866
@ -50,6 +50,8 @@ class _TracerCore(ABC):
|
|||||||
This class provides common methods, and reusable methods for tracers.
|
This class provides common methods, and reusable methods for tracers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
log_missing_parent: bool = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
@ -118,10 +120,11 @@ class _TracerCore(ABC):
|
|||||||
if parent_run := self.run_map.get(str(run.parent_run_id)):
|
if parent_run := self.run_map.get(str(run.parent_run_id)):
|
||||||
self._add_child_run(parent_run, run)
|
self._add_child_run(parent_run, run)
|
||||||
else:
|
else:
|
||||||
logger.warning(
|
if self.log_missing_parent:
|
||||||
f"Parent run {run.parent_run_id} not found for run {run.id}."
|
logger.warning(
|
||||||
" Treating as a root run."
|
f"Parent run {run.parent_run_id} not found for run {run.id}."
|
||||||
)
|
" Treating as a root run."
|
||||||
|
)
|
||||||
run.parent_run_id = None
|
run.parent_run_id = None
|
||||||
run.trace_id = run.id
|
run.trace_id = run.id
|
||||||
run.dotted_order = current_dotted_order
|
run.dotted_order = current_dotted_order
|
||||||
|
@ -18,6 +18,8 @@ AsyncListener = Union[
|
|||||||
class RootListenersTracer(BaseTracer):
|
class RootListenersTracer(BaseTracer):
|
||||||
"""Tracer that calls listeners on run start, end, and error."""
|
"""Tracer that calls listeners on run start, end, and error."""
|
||||||
|
|
||||||
|
log_missing_parent = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
@ -63,6 +65,8 @@ class RootListenersTracer(BaseTracer):
|
|||||||
class AsyncRootListenersTracer(AsyncBaseTracer):
|
class AsyncRootListenersTracer(AsyncBaseTracer):
|
||||||
"""Async Tracer that calls listeners on run start, end, and error."""
|
"""Async Tracer that calls listeners on run start, end, and error."""
|
||||||
|
|
||||||
|
log_missing_parent = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
|
Loading…
Reference in New Issue
Block a user