Skip to content

chore: exclude stacktrace C extension's new location - #875

Open
emmettbutler wants to merge 1 commit into
mainfrom
emmett.butler/strip-stacktrace-ext
Open

emmettbutler wants to merge 1 commit into
mainfrom
emmett.butler/strip-stacktrace-ext

Conversation

@emmettbutler

Copy link
Copy Markdown
Contributor

dd-trace-py is moving its stacktrace C extension, which only IAST uses, from ddtrace/appsec/_shared/ to ddtrace/internal/security/. The layer already strips ddtrace/appsec/_shared for this reason. The new directory also contains modules AAP imports at startup, so only the compiled extension is removed, not the whole directory.

The existing ddtrace/appsec/_shared entry is kept so the layer still strips the extension from ddtrace versions released before the move. rm -rf ignores whichever path doesn't exist, so this works with both old and new ddtrace versions, and the merge order relative to the dd-trace-py change doesn't matter.

Testing Guidelines

The extension isn't imported at serverless startup; dd-trace-py's tests/internal/test_serverless.py asserts this at its new module path.

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future

🤖 Generated with Claude Code

  strip relocated ddtrace stacktrace extension from layer
@emmettbutler
emmettbutler requested review from a team as code owners October 21, 2026 18:01
@emmettbutler emmettbutler changed the title chore: chore: exclude stacktrace C extension's new location Oct 21, 2026

@datadog-prod-us1-3 datadog-prod-us1-3 Bot left a comment

Copy link
Copy Markdown

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 removal glob targets the relocated compiled extension while preserving the security modules needed at startup. The retained legacy path also covers older ddtrace layouts; no reportable defect was identified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit e2c2dff

@rithikanarayan

rithikanarayan commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

@emmettbutler I am currently doing a release for this layer, please don't merge this until at least tomorrow afternoon (assuming this ddtrace change is going out in 4.17 or later, if it's already out pls let me know asap and I'll pause the release) 🙏

@rithikanarayan rithikanarayan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

blocking til release is done, dm if the comment about ddtrace version this responds to is relevant

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

✨ Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/datadog-lambda-python | e2e-test-status — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

ℹ️ Info

🔄 Datadog auto-retried 1 job - 0 passed on retry View in Datadog

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e2c2dff | Docs | View more details | Give us feedback!

gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/dd-trace-py that referenced this pull request Oct 28, 2026
…urity (#21162)

## Description

Removes the 10 dependency direction violations from IAST (`product:iast`) into AAP (`product:aap`). Every one of them pointed at code both products use, so that code now lives in a new `ddtrace/internal/security/` package, which both may import. Being part of `ddtrace.internal`, the package imports no product code.

Extracted from AAP modules:

- `STACK_TRACE` from `ddtrace/appsec/_constants.py` → `ddtrace/internal/security/_constants.py`
- `get_entry_span` and the `_ASM_CONTEXT` core-context key from `ddtrace/appsec/_asm_request_context.py` → `ddtrace/internal/security/_context.py`. `report_stack` needs the entry span; it now looks it up through the shared key instead of importing `_asm_request_context`.
- `_asm_manual_keep` from `ddtrace/appsec/_trace_utils.py` → `ddtrace/internal/security/_trace_utils.py`

The original AAP modules re-export the extracted names, so existing AAP call sites are unchanged. IAST now imports everything from `ddtrace.internal.security`.

## Risks

- The C extension's import path changed from `ddtrace.appsec._shared._stacktrace` to `ddtrace.internal.security._stacktrace`. Packaging that removes the extension by its old path (as the AWS Lambda layer does to keep it out of serverless deployments) needs to remove it at the new path; otherwise the unused extension is shipped. Nothing imports it at serverless startup, so this affects package size only. There's a PR updating the exclusion rule in the Lambda layer here: DataDog/datadog-lambda-python#875

Co-authored-by: emmett.butler <emmett.butler@datadoghq.com>

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