Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/strands/telemetry/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,10 @@ def start_event_loop_cycle_span(
event_loop_cycle_id = str(invocation_state.get("event_loop_cycle_id"))
parent_span = parent_span if parent_span else invocation_state.get("event_loop_parent_span")

attributes: dict[str, AttributeValue] = {
"event_loop.cycle_id": event_loop_cycle_id,
}
attributes: dict[str, AttributeValue] = self._get_common_attributes(
operation_name="execute_event_loop_cycle"
)
attributes["event_loop.cycle_id"] = event_loop_cycle_id

if custom_trace_attributes:
attributes.update(custom_trace_attributes)
Expand Down
10 changes: 9 additions & 1 deletion tests/strands/telemetry/test_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@ def test_start_event_loop_cycle_span(mock_tracer):

mock_span.set_attributes.assert_called_once_with(
{
"gen_ai.operation.name": "execute_event_loop_cycle",
"gen_ai.system": "strands-agents",
"event_loop.cycle_id": "cycle-123",
"request_id": "req-456",
"trace_level": "debug",
Expand Down Expand Up @@ -660,7 +662,13 @@ def test_start_event_loop_cycle_span_latest_conventions(mock_tracer, monkeypatch
mock_tracer.start_span.assert_called_once()
assert mock_tracer.start_span.call_args[1]["name"] == "execute_event_loop_cycle"

mock_span.set_attributes.assert_called_once_with({"event_loop.cycle_id": "cycle-123"})
mock_span.set_attributes.assert_called_once_with(
{
"gen_ai.operation.name": "execute_event_loop_cycle",
"gen_ai.provider.name": "strands-agents",
"event_loop.cycle_id": "cycle-123",
}
)
mock_span.add_event.assert_any_call(
"gen_ai.client.inference.operation.details",
attributes={
Expand Down