Skip to content

chore: remove ddtrace patch.py files from layer#763

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits intomainfrom
brettlangdon/remove.patch.py
Mar 30, 2026
Merged

chore: remove ddtrace patch.py files from layer#763
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits intomainfrom
brettlangdon/remove.patch.py

Conversation

@brettlangdon
Copy link
Copy Markdown
Member

@brettlangdon brettlangdon commented Mar 30, 2026

What does this PR do?

Removes the patch.py source files from the ddtrace package when ddtrace >= 4.7.0rc4.

Motivation

Removing these will save ~800kb from unzipped layer size.

The only reason these were being included is a specific file existence check in _monkey.py that only looks for .py files.

DataDog/dd-trace-py#17196 updates that check to also look for .pyc files, so the lambda layer can drop the patch.py sources. That fix lands in ddtrace 4.7.0rc4.

Implementation

Since there is an indirect version dependency between these two projects, the Dockerfile uses a version gate:

  • ddtrace >= 4.7.0rc4: all .py files are removed (new behavior, ~800kb savings)
  • ddtrace < 4.7.0rc4: patch.py files are kept for instrumentation discovery (old behavior)

Once the minimum ddtrace version in pyproject.toml is bumped past 4.7.0rc4, the version gate can be simplified.

Testing Guidelines

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
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@brettlangdon brettlangdon requested review from a team as code owners March 30, 2026 17:59
@brettlangdon brettlangdon marked this pull request as draft March 30, 2026 18:00
@brettlangdon
Copy link
Copy Markdown
Member Author

Need to think about how to incorporate this change, since it depends on a specific change in dd-trace-py.

@brettlangdon brettlangdon marked this pull request as ready for review March 30, 2026 18:39
Copy link
Copy Markdown
Contributor

@rithikanarayan rithikanarayan left a comment

Choose a reason for hiding this comment

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

LGTM! yay!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants