Skip to content

[BUG] stream_async does not initialize the parent span in opentelemetry #118

Closed
@jros2300

Description

@jros2300

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

0.1.4

Python Version

3.13.1

Operating System

macOS 15.5

Installation Method

pip

Steps to Reproduce

  1. Install Strands using pip
  2. Run an agent call using stream_async, and configure the opentelemetry (to the console or a collector)
  3. Review the spans. The Cycle spans does not have a parent "Strands Agent" span

Expected Behavior

Create a "Strands Agent" Span

Image

Actual Behavior

The parent span is not created

Image

Additional Context

No response

Possible Solution

Initialize the self.tracer in the stream_async method of the Agent class, as it is initialized in the call method.
I'd add this peace of code to the stream_async method:
self.trace_span = self.tracer.start_agent_span( prompt=prompt, model_id=model_id, tools=self.tool_names, system_prompt=self.system_prompt, custom_trace_attributes=self.trace_attributes, )

Related Issues

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions