Skip to content

Commit d1db80f

Browse files
committed
fix(observability): flush a run's shared processors one at a time, in pipeline order
Signed-off-by: Somay-kousis <somaykaush@gmail.com>
1 parent 3d852b9 commit d1db80f

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎packages/nvidia_nat_core/src/nat/observability/exporter/processing_exporter.py‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,14 +555,21 @@ async def _cleanup(self) -> None:
555555
_, still_running = await asyncio.wait(set(self._tasks), timeout=_RUN_END_WAIT_SECONDS)
556556
if still_running:
557557
logger.debug("%s: %d export tasks still running at run end", self.name, len(still_running))
558+
if self.is_isolated_instance:
559+
# in pipeline order: an upstream flush can route items into a downstream processor's buffer
560+
for processor in getattr(self, '_processors', []):
561+
flush_method = getattr(processor, 'flush', None)
562+
if inspect.iscoroutinefunction(flush_method):
563+
try:
564+
await flush_method()
565+
except Exception as e:
566+
logger.exception("Error flushing processor %s: %s", processor.__class__.__name__, e)
567+
await super()._cleanup()
568+
return
569+
558570
shutdown_tasks = []
559571
for processor in getattr(self, '_processors', []):
560-
if self.is_isolated_instance:
561-
shutdown_method = getattr(processor, 'flush', None)
562-
if not inspect.iscoroutinefunction(shutdown_method):
563-
shutdown_method = None
564-
else:
565-
shutdown_method = getattr(processor, 'shutdown', None)
572+
shutdown_method = getattr(processor, 'shutdown', None)
566573
if shutdown_method:
567574
logger.debug("Shutting down processor: %s", processor.__class__.__name__)
568575
shutdown_tasks.append(shutdown_method())

0 commit comments

Comments
 (0)