Repository navigation
fix(layer): detect ddtrace_serverless version so contrib .py files are removed - #901
Merged
Merged
Conversation
…e removed Wheels from dd-trace-py CI built with DD_SERVERLESS_BUILD=1 install as the ddtrace_serverless distribution. The .py cleanup step only read ddtrace-*.dist-info/METADATA, so the version came back empty, the packaging check raised InvalidVersion, and the fallback branch kept every ddtrace/contrib/**/patch.py (~720 kB) in the layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 of 11 tasks
Contributor
There was a problem hiding this comment.
More details
The metadata lookup handles either wheel distribution when the other metadata path is absent, while preserving the existing version-gated cleanup behavior.
🤖 Bits Code Review · Commit 7893b5c
Contributor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 4, 2026
litianningdatadog
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Reads the ddtrace version from either
ddtrace-*.dist-infoorddtrace_serverless-*.dist-infoin the.pycleanup step of the layer Dockerfile.Motivation
The downstream pipeline that dd-trace-py triggers (
UPSTREAM_PIPELINE_ID) installs theddtrace_serverlesswheel (built withDD_SERVERLESS_BUILD=1). Its metadata is inddtrace_serverless-<ver>.dist-info, so thegrep … ddtrace-*.dist-info/METADATAstep returned nothing.Version('')then raisedInvalidVersion, and theelsebranch kept everyddtrace/contrib/**/patch.py. Those are 106 files, about 720 kB, shipped next to their.pycfiles. From the build log:This is a large part of why
check-layer-sizefails on dd-trace-py main builds. Layers built from the PyPIddtracewheel were not affected.Results (Python 3.15, amd64, dd-trace-py main pipeline 157654945,
ddtrace_serverless4.18.0rc1)Testing Guidelines
UPSTREAM_PIPELINE_ID=157654945 PYTHON_VERSION=3.15 ARCH=amd64 ./scripts/build_layers.shand rancheck_layer_size.sh(numbers above). The build log now printsDetected ddtrace version: 4.18.0rc1, and the layer has no.pyfiles left.public.ecr.aws/sam/build-python3.15:1: patched botocore, urllib3, httplib, sqlite3, logging, aiohttp, flask and subprocess, then invokeddatadog_lambda.handleron an API Gateway event. It producedaws.lambda,aws.lambda.load,aws.lambda.importandsqlite.queryspans, the same as main. Integration discovery from.pycworks for ddtrace ≥ 4.7.0rc3 (chore(tracer): contrib checking for patch.py and patch.pyc dd-trace-py#17196).Additional Notes
Not addressed here:
ddtrace.__version__reports0.0.0with the serverless wheel, because importlib can't find addtracedistribution. This only affects CI builds from upstream wheels.Types of Changes
Check all that apply
🤖 Generated with Claude Code