feat(chalice): Add span streaming support to Chalice integration#6503
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