Skip to content

feat: initialize SCA reachability in the Lambda wrapper - #880

Open
florentinl wants to merge 7 commits into
mainfrom
flabel/sca-startup
Open

florentinl wants to merge 7 commits into
mainfrom
flabel/sca-startup

Conversation

@florentinl

@florentinl florentinl commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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.send call 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.

gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/dd-trace-py that referenced this pull request Nov 9, 2026
## 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>
@florentinl
florentinl marked this pull request as ready for review November 16, 2026 13:11
@florentinl
florentinl requested review from a team as code owners November 16, 2026 13:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T15:53:42.012105Z 1ce368c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

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.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 68bb057

@datadog-official

datadog-official Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1ce368c | Docs | Give us feedback!

@florentinl
florentinl marked this pull request as draft November 16, 2026 13:41
Comment thread datadog_lambda/patch.py Resolved
Comment thread Dockerfile Resolved
@florentinl
florentinl marked this pull request as ready for review November 17, 2026 15:52

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

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.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 1ce368c

Comment thread datadog_lambda/config.py
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants