Skip to content

Commit 78c59b9

Browse files
authored
fix(telemetry): make strands agent invoke_agent span as INTERNAL spanKind (#1055)
* fix(telemetry): make strands agent invoke_agent and chat span as INTERNAL spanKind
1 parent b69478b commit 78c59b9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/strands/telemetry/tracer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def start_model_invoke_span(
293293
# Add additional kwargs as attributes
294294
attributes.update({k: v for k, v in kwargs.items() if isinstance(v, (str, int, float, bool))})
295295

296-
span = self._start_span("chat", parent_span, attributes=attributes, span_kind=trace_api.SpanKind.CLIENT)
296+
span = self._start_span("chat", parent_span, attributes=attributes, span_kind=trace_api.SpanKind.INTERNAL)
297297
self._add_event_messages(span, messages)
298298

299299
return span
@@ -588,7 +588,7 @@ def start_agent_span(
588588
attributes.update({k: v for k, v in kwargs.items() if isinstance(v, (str, int, float, bool))})
589589

590590
span = self._start_span(
591-
f"invoke_agent {agent_name}", attributes=attributes, span_kind=trace_api.SpanKind.CLIENT
591+
f"invoke_agent {agent_name}", attributes=attributes, span_kind=trace_api.SpanKind.INTERNAL
592592
)
593593
self._add_event_messages(span, messages)
594594

tests/strands/telemetry/test_tracer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_start_model_invoke_span(mock_tracer):
153153

154154
mock_tracer.start_span.assert_called_once()
155155
assert mock_tracer.start_span.call_args[1]["name"] == "chat"
156-
assert mock_tracer.start_span.call_args[1]["kind"] == SpanKind.CLIENT
156+
assert mock_tracer.start_span.call_args[1]["kind"] == SpanKind.INTERNAL
157157
mock_span.set_attribute.assert_any_call("gen_ai.system", "strands-agents")
158158
mock_span.set_attribute.assert_any_call("gen_ai.operation.name", "chat")
159159
mock_span.set_attribute.assert_any_call("gen_ai.request.model", model_id)
@@ -188,7 +188,7 @@ def test_start_model_invoke_span_latest_conventions(mock_tracer):
188188

189189
mock_tracer.start_span.assert_called_once()
190190
assert mock_tracer.start_span.call_args[1]["name"] == "chat"
191-
assert mock_tracer.start_span.call_args[1]["kind"] == SpanKind.CLIENT
191+
assert mock_tracer.start_span.call_args[1]["kind"] == SpanKind.INTERNAL
192192
mock_span.set_attribute.assert_any_call("gen_ai.provider.name", "strands-agents")
193193
mock_span.set_attribute.assert_any_call("gen_ai.operation.name", "chat")
194194
mock_span.set_attribute.assert_any_call("gen_ai.request.model", model_id)
@@ -670,6 +670,7 @@ def test_start_agent_span(mock_tracer):
670670

671671
mock_tracer.start_span.assert_called_once()
672672
assert mock_tracer.start_span.call_args[1]["name"] == "invoke_agent WeatherAgent"
673+
assert mock_tracer.start_span.call_args[1]["kind"] == SpanKind.INTERNAL
673674
mock_span.set_attribute.assert_any_call("gen_ai.system", "strands-agents")
674675
mock_span.set_attribute.assert_any_call("gen_ai.agent.name", "WeatherAgent")
675676
mock_span.set_attribute.assert_any_call("gen_ai.request.model", model_id)

0 commit comments

Comments
 (0)