Open
Description
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.8
Python Version
3.10
Operating System
macOS 15.5
Installation Method
other
Steps to Reproduce
Setup:
- Python Lambda deployed with Dockerfile on ARM64
- ADOT Python Lambda Layer:
arn:aws:lambda:us-west-2:901920570463:layer:aws-otel-python-arm64-ver-1-32-0:2
- CDK Lambda property set to
tracing: Tracing.ACTIVE
extensions:
sigv4auth:
service: xray
region: ${env:AWS_REGION}
receivers:
otlp:
protocols:
# Strands Agents SDK uses Http OTLP exporter
# https://github.com/strands-agents/sdk-python/blob/d8ce2d5e69322211b281567eb0da99e0ba47b574/src/strands/telemetry/tracer.py#L38
http:
endpoint: 'localhost:4318'
exporters:
otlphttp:
compression: gzip
traces_endpoint: https://xray.${env:AWS_REGION}.amazonaws.com/v1/traces
auth:
authenticator: sigv4auth
service:
extensions: [sigv4auth]
pipelines:
traces:
receivers: [otlp]
exporters: [otlphttp]
# Instantiate Tracer
tracer = get_tracer(service_name="JvlinStrandsAgents", otlp_endpoint="http://localhost:4318/")
AWS X-Ray trace service map:
Expected Behavior
Expecting Lambda Context, Lambda Function to be the only nodes as Strands Agents SDK runs internally within the Lambda Function itself.
The Strands Agents SDK created spans should be within the Invocation
span parent.
Actual Behavior
Current tracer implementation:
def _start_span(
self,
span_name: str,
parent_span: Optional[Span] = None,
attributes: Optional[Dict[str, AttributeValue]] = None,
) -> Optional[Span]:
"""Generic helper method to start a span with common attributes.
Args:
span_name: Name of the span to create
parent_span: Optional parent span to link this span to
attributes: Dictionary of attributes to set on the span
Returns:
The created span, or None if tracing is not enabled
"""
if self.tracer is None:
return None
context = trace_api.set_span_in_context(parent_span) if parent_span else None
span = self.tracer.start_span(name=span_name, context=context)
# Set start time as a common attribute
span.set_attribute("gen_ai.event.start_time", datetime.now(timezone.utc).isoformat())
# Add all provided attributes
if attributes:
self._set_attributes(span, attributes)
return span
To be modified so that existing span context coming from outside of the Strands Agents SDK is used.
Additional Context
No response
Possible Solution
No response
Related Issues
No response