Skip to content

feat(chalice): Add span streaming support to Chalice integration#6503

Merged
ericapisani merged 12 commits into
masterfrom
py-2312-migrate-chalice
Jun 12, 2026
Merged

feat(chalice): Add span streaming support to Chalice integration#6503
ericapisani merged 12 commits into
masterfrom
py-2312-migrate-chalice

address potential data loss issue - https://github.com/getsentry/sent…

d637c2f
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Jun 4, 2026 in 11m 10s

2 issues

Medium

Missing `continue_trace` call before `start_span` breaks distributed tracing in streaming path - `sentry_sdk/integrations/chalice.py:122-135`

In the streaming path, sentry_sdk.traces.continue_trace(headers) is never called before start_span, so incoming sentry-trace/traceparent/baggage headers from HTTP requests are never propagated — every Chalice invocation starts a fresh, unconnected trace instead of joining the upstream trace. Add sentry_sdk.traces.continue_trace(headers) before the start_span call (mirroring the GCP integration at gcp.py:133).

Low

_get_lambda_span_attributes crashes when invoked_function_arn is None (chalice local) - `tests/integrations/chalice/test_chalice.py:104-106`

In sentry_sdk/integrations/chalice.py, _get_lambda_span_attributes calls invoked_arn.split(':') without a null guard. In real AWS Lambda the runtime always populates invoked_function_arn, but chalice.app.LambdaContext (used by chalice local) leaves it as None by default. When span streaming is enabled (trace_lifecycle=stream) and running under chalice local, both streaming paths (EventSourceHandler.__call__ and _get_view_function_response.wrapped_view_function) call _get_lambda_span_attributes outside capture_internal_exceptions, so the resulting AttributeError: 'NoneType' object has no attribute 'split' propagates and crashes the handler. Production AWS Lambda is unaffected. Fix by defaulting to an empty string: invoked_arn = aws_context.invoked_function_arn or ''.

4 skills analyzed
Skill Findings Duration Cost
security-review 0 38.8s $0.11
code-review 0 4m 10s $0.77
find-bugs 2 10m 37s $1.75
skill-scanner 0 51.0s $0.05

⏱ 16m 17s · 1.5M in / 77.8k out · $2.68