-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Include all trace export payloads #1349
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
Conversation
* Correct the `httpx.Timeout` call to use separate `connect` and `read` timeouts * Prevent client initialization errors by using a valid timeout signature * Remove the `if item.export()` filter so no exported data is dropped * Ensure empty or falsy `export()` results are still sent to the backend * Improve reliability of trace exports without changing existing APIs
* Adds a default timeout to the `httpx.Timeout` config to avoid runtime errors during client initialization (required by older HTTPX versions). * Ensures that all items from `item.export()` are included in the payload, even if empty or falsy, for complete trace logging. * Fix maintains backward compatibility and passes all Python 3.9+ tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the second change is really relevant, we may be interested in it. That said, we need more information on it.
@@ -96,7 +97,8 @@ def export(self, items: list[Trace | Span[Any]]) -> None: | |||
logger.warning("OPENAI_API_KEY is not set, skipping trace export") | |||
return | |||
|
|||
data = [item.export() for item in items if item.export()] | |||
# include all export() results, even if they’re empty/falsy | |||
data = [item.export() for item in items] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate more on this? If there is a certain situation to resolve, we're happy to adjust this logic, but we aren't aware of anything.
src/agents/tracing/processors.py
Outdated
@@ -60,7 +60,8 @@ def __init__( | |||
self.max_delay = max_delay | |||
|
|||
# Keep a client open for connection pooling across multiple export calls | |||
self._client = httpx.Client(timeout=httpx.Timeout(timeout=60, connect=5.0)) | |||
# use separate connect/read timeouts | |||
self._client = httpx.Client(timeout=httpx.Timeout(60.0, connect=5.0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't change anything on the actual behavior, so we don't need this change.
We made Bottom line: the core tracer should hand over every export result, even if it’s empty. If a backend or custom exporter wants to drop empties, they can do that themselves where it’s obvious and logged, not buried in the heart of the tracing code. |
Thanks for your reply, but changing the behavior could break existing integrations' behaviors, plus I don't see the necessity to send empty data to tracing data platform as it does not provide meaningful information. Thanks again for sending this but let me close it now. |
httpx.Timeout
for full compatibility with older versionsitem.export()
results in the export payload, even falsy ones