From 85017597c12e47683db4e32412185b25e95b0fed Mon Sep 17 00:00:00 2001 From: poshinchen Date: Sun, 13 Jul 2025 22:20:51 -0400 Subject: [PATCH] chore: update span names --- src/strands/telemetry/tracer.py | 4 ++-- tests/strands/telemetry/test_tracer.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/strands/telemetry/tracer.py b/src/strands/telemetry/tracer.py index ff3f832ad..849b8d57b 100644 --- a/src/strands/telemetry/tracer.py +++ b/src/strands/telemetry/tracer.py @@ -235,7 +235,7 @@ def start_model_invoke_span( # Add additional kwargs as attributes attributes.update({k: v for k, v in kwargs.items() if isinstance(v, (str, int, float, bool))}) - span = self._start_span("Model invoke", parent_span, attributes, span_kind=trace_api.SpanKind.CLIENT) + span = self._start_span("chat", parent_span, attributes, span_kind=trace_api.SpanKind.CLIENT) for message in messages: self._add_event( span, @@ -371,7 +371,7 @@ def start_event_loop_cycle_span( # Add additional kwargs as attributes attributes.update({k: v for k, v in kwargs.items() if isinstance(v, (str, int, float, bool))}) - span_name = f"Cycle {event_loop_cycle_id}" + span_name = "execute_event_loop_cycle" span = self._start_span(span_name, parent_span, attributes) for message in messages or []: self._add_event( diff --git a/tests/strands/telemetry/test_tracer.py b/tests/strands/telemetry/test_tracer.py index 7623085f2..06b02bccb 100644 --- a/tests/strands/telemetry/test_tracer.py +++ b/tests/strands/telemetry/test_tracer.py @@ -151,7 +151,7 @@ def test_start_model_invoke_span(mock_tracer): span = tracer.start_model_invoke_span(messages=messages, agent_name="TestAgent", model_id=model_id) mock_tracer.start_span.assert_called_once() - assert mock_tracer.start_span.call_args[1]["name"] == "Model invoke" + assert mock_tracer.start_span.call_args[1]["name"] == "chat" assert mock_tracer.start_span.call_args[1]["kind"] == SpanKind.CLIENT mock_span.set_attribute.assert_any_call("gen_ai.system", "strands-agents") mock_span.set_attribute.assert_any_call("gen_ai.operation.name", "chat") @@ -240,7 +240,7 @@ def test_start_event_loop_cycle_span(mock_tracer): span = tracer.start_event_loop_cycle_span(event_loop_kwargs, messages=messages) mock_tracer.start_span.assert_called_once() - assert mock_tracer.start_span.call_args[1]["name"] == "Cycle cycle-123" + assert mock_tracer.start_span.call_args[1]["name"] == "execute_event_loop_cycle" mock_span.set_attribute.assert_any_call("event_loop.cycle_id", "cycle-123") mock_span.add_event.assert_any_call( "gen_ai.user.message", attributes={"content": json.dumps([{"text": "Hello"}])}