From 894c8468d61d315f712a810fa4aff39752a76697 Mon Sep 17 00:00:00 2001 From: Teo Date: Mon, 25 Nov 2024 22:20:42 -0600 Subject: [PATCH] feat(session): force flush pending spans on session end --- agentops/session.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agentops/session.py b/agentops/session.py index a1d7171b..29dcb23e 100644 --- a/agentops/session.py +++ b/agentops/session.py @@ -285,6 +285,10 @@ def end_session( return None try: + # Force flush any pending spans before ending session + if hasattr(self, "_span_processor"): + self._span_processor.force_flush(timeout_millis=5000) + # 1. Set shutdown flag on exporter first if hasattr(self, "_otel_exporter"): self._otel_exporter.shutdown()