Closed
Description
Issue
In the export
method in processor.py
the following code lines do not update the traces
and spans
variables -
traces: list[dict[str, Any]] = []
spans: list[dict[str, Any]] = []
data = [item.export() for item in items if item.export()]
payload = {"data": data}
headers = {
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json",
"OpenAI-Beta": "traces=v1",
}
Hence, in the debug logs you won't see the correct values when this code is run -
# Exponential backoff loop
attempt = 0
delay = self.base_delay
while True:
attempt += 1
try:
response = self._client.post(url=self.endpoint, headers=headers, json=payload)
# If the response is successful, break out of the loop
if response.status_code < 300:
logger.debug(f"Exported {len(traces)} traces, {len(spans)} spans")
return
Solution
Updating the above code snippet with the following solves the issue -
traces: list[dict[str, Any]] = []
spans: list[dict[str, Any]] = []
# Categorize items into traces and spans
for item in items:
if hasattr(item, 'export') and callable(item.export):
export_data = item.export()
if export_data:
if isinstance(item, Trace):
traces.append(export_data)
else:
spans.append(export_data)
data = traces + spans
payload = {"data": data}
Metadata
Metadata
Assignees
Labels
No labels