Skip to content

Commit e1f1490

Browse files
committed
update span name
1 parent ab37f2d commit e1f1490

4 files changed

Lines changed: 25 additions & 24 deletions

File tree

deepeval/openai_agents/callback_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def on_span_start(self, span: Span) -> None:
5656
observer = Observer(span_type=span_type, func_name="NA")
5757
if span_type == "llm":
5858
observer.observe_kwargs["model"] = "temporary model"
59-
observer.custom_update_span_attributes = (
60-
lambda span_type: custom_update_span_attributes(span_type, span.span_data)
59+
observer.update_span_properties = (
60+
lambda span_type: update_span_properties(span_type, span.span_data)
6161
)
6262
self.span_observers[span.span_id] = observer
6363
observer.__enter__()

deepeval/openai_agents/extractors.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,34 @@ def _check_openai_agents_available():
4646
"openai-agents is required for this integration. Install it via your package manager"
4747
)
4848

49-
def custom_update_span_attributes(span: BaseSpan, span_data: SpanData):
49+
def update_span_properties(span: BaseSpan, span_data: SpanData):
5050
_check_openai_agents_available()
5151
# LLM Span
5252
if isinstance(span_data, ResponseSpanData):
53-
update_attributes_from_response_span_data(span, span_data)
53+
update_span_properties_from_response_span_data(span, span_data)
5454
elif isinstance(span_data, GenerationSpanData):
55-
udpate_attributes_from_generation_span_data(span, span_data)
55+
update_span_properties_from_generation_span_data(span, span_data)
5656
# Tool Span
5757
elif isinstance(span_data, FunctionSpanData):
58-
update_attributes_from_function_span_data(span, span_data)
58+
update_span_properties_from_function_span_data(span, span_data)
5959
elif isinstance(span_data, MCPListToolsSpanData):
60-
update_attributes_from_mcp_list_tool_span_data(span, span_data)
60+
update_span_properties_from_mcp_list_tool_span_data(span, span_data)
6161
# Agent Span
6262
elif isinstance(span_data, AgentSpanData):
63-
update_attributes_from_agent_span_data(span, span_data)
63+
update_span_properties_from_agent_span_data(span, span_data)
6464
# Custom Span
6565
elif isinstance(span_data, HandoffSpanData):
66-
update_attributes_from_handoff_span_data(span, span_data)
66+
update_span_properties_from_handoff_span_data(span, span_data)
6767
elif isinstance(span_data, CustomSpanData):
68-
update_attributes_from_custom_span_data(span, span_data)
68+
update_span_properties_from_custom_span_data(span, span_data)
6969
elif isinstance(span_data, GuardrailSpanData):
70-
update_attributes_from_guardrail_span_data(span, span_data)
70+
update_span_properties_from_guardrail_span_data(span, span_data)
7171

7272
########################################################
7373
### LLM Span ###########################################
7474
########################################################
7575

76-
def update_attributes_from_response_span_data(
76+
def update_span_properties_from_response_span_data(
7777
span: LlmSpan,
7878
span_data: ResponseSpanData,
7979
):
@@ -114,7 +114,7 @@ def update_attributes_from_response_span_data(
114114
span.output = output
115115
span.name = "LLM Generation"
116116

117-
def udpate_attributes_from_generation_span_data(
117+
def update_span_properties_from_generation_span_data(
118118
span: LlmSpan,
119119
generation_span_data: GenerationSpanData,
120120
):
@@ -146,7 +146,7 @@ def udpate_attributes_from_generation_span_data(
146146
### Tool Span ##########################################
147147
########################################################
148148

149-
def update_attributes_from_function_span_data(
149+
def update_span_properties_from_function_span_data(
150150
span: ToolSpan,
151151
function_span_data: FunctionSpanData,
152152
):
@@ -159,7 +159,7 @@ def update_attributes_from_function_span_data(
159159
span.name = "Function tool: " + function_span_data.name if function_span_data.name else "Function tool"
160160
span.description = "Function tool"
161161

162-
def update_attributes_from_mcp_list_tool_span_data(
162+
def update_span_properties_from_mcp_list_tool_span_data(
163163
span: ToolSpan,
164164
mcp_list_tool_span_data: MCPListToolsSpanData,
165165
) :
@@ -177,7 +177,7 @@ def update_attributes_from_mcp_list_tool_span_data(
177177
### Agent Span #########################################
178178
########################################################
179179

180-
def update_attributes_from_agent_span_data(
180+
def update_span_properties_from_agent_span_data(
181181
span: AgentSpan,
182182
agent_span_data: AgentSpanData
183183
):
@@ -197,7 +197,7 @@ def update_attributes_from_agent_span_data(
197197
### Custom Span #######################################
198198
########################################################
199199

200-
def update_attributes_from_handoff_span_data(
200+
def update_span_properties_from_handoff_span_data(
201201
span: AgentSpan,
202202
handoff_span_data: HandoffSpanData
203203
):
@@ -211,15 +211,15 @@ def update_attributes_from_handoff_span_data(
211211
span.input = None
212212
span.output = None
213213

214-
def update_attributes_from_custom_span_data(
214+
def update_span_properties_from_custom_span_data(
215215
span: BaseSpan,
216216
custom_span_data: CustomSpanData
217217
):
218218
# Update Span
219219
span.name = custom_span_data.name
220220
span.metadata = {"data": custom_span_data.data}
221221

222-
def update_attributes_from_guardrail_span_data(
222+
def update_span_properties_from_guardrail_span_data(
223223
span: BaseSpan,
224224
guardrail_span_data: GuardrailSpanData
225225
):

deepeval/tracing/tracing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def __init__(
704704
)
705705
self._progress = _progress
706706
self._pbar_callback_id = _pbar_callback_id
707-
self.custom_update_span_attributes: Optional[Callable] = None
707+
self.update_span_properties: Optional[Callable] = None
708708

709709
def __enter__(self):
710710
"""Enter the tracer context, creating a new span and setting up parent-child relationships."""
@@ -774,8 +774,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):
774774
else:
775775
current_span.status = TraceSpanStatus.SUCCESS
776776

777-
if self.custom_update_span_attributes is not None:
778-
self.custom_update_span_attributes(current_span)
777+
if self.update_span_properties is not None:
778+
self.update_span_properties(current_span)
779779
else:
780780
self.update_span_attributes(current_span)
781781

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import asyncio
22
from openai.types.responses import ResponseTextDeltaEvent
33
from agents import Agent, Runner
4-
4+
'
5+
'
56
async def streaming_agent():
67
agent = Agent(
78
name="Joker",
@@ -10,4 +11,4 @@ async def streaming_agent():
1011
result = Runner.run_streamed(agent, input="Please tell me 5 jokes.")
1112
async for event in result.stream_events():
1213
if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent):
13-
print(event.data.delta, end="", flush=True)
14+
print(event.data.delta, end="", flush=True)

0 commit comments

Comments
 (0)