Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Tracing OpenAI Agents SDK #1572

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
use exception logging for stack traces
  • Loading branch information
angus-langchain committed Mar 12, 2025
commit ce1d4e23b375f22c73fd9a3862c29e9fd1931c0b
12 changes: 4 additions & 8 deletions python/langsmith/wrappers/_openai_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def on_trace_start(self, trace: tracing.Trace) -> None:
)
self.client.create_run(**run_data)
except Exception as e:
logger.error(f"Error creating trace run: {e}")
logger.exception(f"Error creating trace run: {e}")

def on_trace_end(self, trace: tracing.Trace) -> None:
run_id = self._runs.pop(trace.trace_id, None)
Expand All @@ -180,14 +180,10 @@ def on_trace_end(self, trace: tracing.Trace) -> None:
run_id=run_id,
)
except Exception as e:
logger.error(f"Error updating trace run: {e}")
logger.exception(f"Error updating trace run: {e}")

def on_span_start(self, span: tracing.Span) -> None:
parent_run_id = None
if span.parent_id:
parent_run_id = self._runs.get(span.parent_id)
else:
parent_run_id = self._runs.get(span.trace_id)
parent_run_id = self._runs.get(span.parent_id or span.trace_id)
span_run_id = str(uuid.uuid4())
self._runs[span.span_id] = span_run_id

Expand All @@ -204,7 +200,7 @@ def on_span_start(self, span: tracing.Span) -> None:
)
self.client.create_run(**run_data)
except Exception as e:
logger.error(f"Error creating span run: {e}")
logger.exception(f"Error creating span run: {e}")

def on_span_end(self, span: tracing.Span) -> None:
run_id = self._runs.pop(span.span_id, None)
Expand Down
Loading