Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/openlayer/lib/integrations/langchain_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ def _end_step(
and tracer.get_current_step() is None
):
trace = self._traces_by_root.pop(run_id)
self._process_and_upload_trace(trace)
if tracer._configured_background_publish_enabled:
tracer._get_background_executor().submit(
self._process_and_upload_trace, trace
)
else:
self._process_and_upload_trace(trace)

def _process_and_upload_trace(self, trace: traces.Trace) -> None:
"""Process and upload the completed trace (only for standalone root steps)."""
Expand Down Expand Up @@ -1241,7 +1246,12 @@ def _end_step(
# Only upload if: root step + has standalone trace + not part of external trace
if is_root_step and has_standalone_trace and not self._has_external_trace:
trace = self._traces_by_root.pop(run_id)
self._process_and_upload_async_trace(trace)
if tracer._configured_background_publish_enabled:
tracer._get_background_executor().submit(
self._process_and_upload_async_trace, trace
)
else:
self._process_and_upload_async_trace(trace)

def _process_and_upload_async_trace(self, trace: traces.Trace) -> None:
"""Process and upload trace for async handler."""
Expand Down