Skip to content

Improve tracing error messages #311

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

Merged
merged 1 commit into from
Mar 23, 2025
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
12 changes: 8 additions & 4 deletions src/agents/tracing/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,22 @@ def export(self, items: list[Trace | Span[Any]]) -> None:

# If the response is a client error (4xx), we wont retry
if 400 <= response.status_code < 500:
logger.error(f"Tracing client error {response.status_code}: {response.text}")
logger.error(
f"[non-fatal] Tracing client error {response.status_code}: {response.text}"
)
return

# For 5xx or other unexpected codes, treat it as transient and retry
logger.warning(f"Server error {response.status_code}, retrying.")
logger.warning(
f"[non-fatal] Tracing: server error {response.status_code}, retrying."
)
except httpx.RequestError as exc:
# Network or other I/O error, we'll retry
logger.warning(f"Request failed: {exc}")
logger.warning(f"[non-fatal] Tracing: request failed: {exc}")

# If we reach here, we need to retry or give up
if attempt >= self.max_retries:
logger.error("Max retries reached, giving up on this batch.")
logger.error("[non-fatal] Tracing: max retries reached, giving up on this batch.")
return

# Exponential backoff + jitter
Expand Down