From 93bca7bf116c25de216dae778b874cd4130eebb7 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Wed, 12 Mar 2025 10:14:01 +0530 Subject: [PATCH 1/3] count both spans and traces --- src/agents/tracing/processors.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/agents/tracing/processors.py b/src/agents/tracing/processors.py index 282bc23c..f325e869 100644 --- a/src/agents/tracing/processors.py +++ b/src/agents/tracing/processors.py @@ -81,7 +81,17 @@ class BackendSpanExporter(TracingExporter): traces: list[dict[str, Any]] = [] spans: list[dict[str, Any]] = [] - data = [item.export() for item in items if item.export()] + # 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} headers = { From ac571ceec1ac35bd3c671ca7dc59127979477857 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Wed, 12 Mar 2025 10:19:14 +0530 Subject: [PATCH 2/3] Revert "count both spans and traces" This reverts commit 93bca7bf116c25de216dae778b874cd4130eebb7. --- src/agents/tracing/processors.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/agents/tracing/processors.py b/src/agents/tracing/processors.py index f325e869..282bc23c 100644 --- a/src/agents/tracing/processors.py +++ b/src/agents/tracing/processors.py @@ -81,17 +81,7 @@ class BackendSpanExporter(TracingExporter): 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 + data = [item.export() for item in items if item.export()] payload = {"data": data} headers = { From 72e35288de3bfd4e45ebdee8f203504e0d6cc102 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Wed, 12 Mar 2025 10:20:15 +0530 Subject: [PATCH 3/3] resort to show total number of spans and traces --- src/agents/tracing/processors.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/agents/tracing/processors.py b/src/agents/tracing/processors.py index 282bc23c..308adf2a 100644 --- a/src/agents/tracing/processors.py +++ b/src/agents/tracing/processors.py @@ -78,9 +78,6 @@ class BackendSpanExporter(TracingExporter): logger.warning("OPENAI_API_KEY is not set, skipping trace export") return - traces: list[dict[str, Any]] = [] - spans: list[dict[str, Any]] = [] - data = [item.export() for item in items if item.export()] payload = {"data": data} @@ -100,7 +97,7 @@ class BackendSpanExporter(TracingExporter): # 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") + logger.debug(f"Exported {len(items)} items") return # If the response is a client error (4xx), we wont retry