[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. 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

View File

@ -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,
*, *,