Repository navigation
feat: initialize SCA reachability in the Lambda wrapper - #880
florentinl wants to merge 7 commits into
Conversation
## Description Enable SCA reachability in AWS Lambda. Requires the [Lambda startup change](DataDog/datadog-lambda-python#880); [system-tests coverage](DataDog/system-tests#8224) is separate. ## Testing 127 SCA tests, 12 regular/Lambda Flask telemetry cases, and five Lambda reachability checks pass on Colima. The Lambda reachability case fails with the old exclusion restored. Lint passes. ## Risks Lambda cold-start overhead is unmeasured. Co-authored-by: florentin.labelle <florentin.labelle@datadoghq.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
SCA initialization failures are caught, preserving handler startup when SCA is unavailable. Runtime behavior could not be exercised because ddtrace is not installed in the review environment.
🤖 Bits Code Review · Commit 68bb057
There was a problem hiding this comment.
More details
The startup sequence defers Lambda integration patching until SCA initialization has been attempted, and catches SCA failures so handler startup can continue. Runtime verification was blocked by the missing ddtrace dependency.
🤖 Bits Code Review · Commit 1ce368c
| capture_payload_enabled = _get_env("DD_CAPTURE_LAMBDA_PAYLOAD", "false", as_bool) | ||
|
|
||
| trace_enabled = _get_env("DD_TRACE_ENABLED", "true", as_bool) | ||
| aws_lambda_enabled = _get_env("DD_TRACE_AWS_LAMBDA_ENABLED", "true", as_bool) |
There was a problem hiding this comment.
| aws_lambda_enabled = _get_env("DD_TRACE_AWS_LAMBDA_ENABLED", "true", as_bool) | |
| # ddtrace's DD_TRACE_<PACKAGE>_ENABLED turns instrumentation on/off per package | |
| aws_lambda_enabled = _get_env("DD_TRACE_AWS_LAMBDA_ENABLED", "true", as_bool) |
What does this PR do?
Initialize SCA reachability before user handler imports when enabled, and retain its modules in packaged layers. Patch the other integrations first, then initialize SCA before enabling the Lambda integration, which can import the handler itself. Preserve the Lambda integration's disable setting and continue tracing if SCA startup fails.
Requires dd-trace-py#21366.
Testing Guidelines
The affected wrapper, handler, configuration, span-pointer, and startup tests pass on Python 3.9, 3.12, and 3.14: 384 tests per version. The fresh-process startup regression fails against the previous code and passes with tracing and the Lambda integration independently enabled or disabled. Import and startup failures remain covered.
A compiled-only Lambda layer detects a real
requests.Session.sendcall during handler import with tracing both enabled and disabled, using a synthetic advisory and ddtrace main. All five SCA system tests pass across all five Lambda HTTP variants with the same tracer and the local test-side wait for initial telemetry.Repository formatting and the Python 3.9 CI lint checks pass.