[Core] Logging: Suppress missing parent warning (#23363)

This commit is contained in:
William FH 2024-06-25 11:57:23 -07:00 committed by GitHub
parent 730c551819
commit 8955bc1866
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -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,
*,
@ -118,10 +120,11 @@ class _TracerCore(ABC):
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

View File

@ -18,6 +18,8 @@ AsyncListener = Union[
class RootListenersTracer(BaseTracer):
"""Tracer that calls listeners on run start, end, and error."""
log_missing_parent = False
def __init__(
self,
*,
@ -63,6 +65,8 @@ class RootListenersTracer(BaseTracer):
class AsyncRootListenersTracer(AsyncBaseTracer):
"""Async Tracer that calls listeners on run start, end, and error."""
log_missing_parent = False
def __init__(
self,
*,