Ship the injector bootstrap script (sitecustomize.py) in the distro wheel#34
Merged
Conversation
…heel Move the sitecustomize.py that the OpenTelemetry injector triggers via PYTHONPATH from the dash0-operator repository into the dash0-opentelemetry-distro wheel, at dash0/opentelemetry/injector/sitecustomize.py. Consumers building an injectable tree (pip install --target <dir>) copy it from its packaged location to <dir>/sitecustomize.py, so the script is versioned and tested together with the tree it bootstraps. Two deliberate deviations from the operator's copy: - Split PYTHONPATH on os.pathsep (previously ","), so self-deactivation also removes the injected site when PYTHONPATH has multiple entries. - Derive the double-instrumentation check from the OpenTelemetry packages actually installed in the injected tree (the pinned dependency closure of this package), instead of a hardcoded list. API-layer packages (opentelemetry-api, -semantic-conventions) are excluded: applications legitimately use them for manual instrumentation; version conflicts with them are still caught by the all-dependencies.txt check. The script stays valid Python 2.7+ so it can self-deactivate gracefully on interpreters the distribution does not support; it is excluded from ruff for that reason.
mmanciop
added a commit
to dash0hq/dash0-operator
that referenced
this pull request
Jul 23, 2026
…distribution Follows dash0hq/opentelemetry-python-distribution#34: the injector bootstrap script and its unit tests now live inside the dash0-opentelemetry-distro wheel. The instrumentation image copies the packaged file to <target>/sitecustomize.py after pip install, per the distribution's deployment contract. Drops the local copy of the script, its unit tests, the make target and the CI job that ran them.
mmanciop
enabled auto-merge (squash)
July 23, 2026 12:39
ocelotl
approved these changes
Jul 23, 2026
Merged
mmanciop
added a commit
that referenced
this pull request
Jul 23, 2026
Fold the pending chloggen entry into the 0.2.0 - 2026-07-23 changelog section. The version bump to 0.2.0 already landed with #34; uv.lock is already current.
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.
Closes #32.
Moves the
sitecustomize.pythat the OpenTelemetry injector triggers viaPYTHONPATHfrom the dash0-operator repository (in its dash0hq/dash0-operator#1248 form, already adapted to this distribution) into thedash0-opentelemetry-distrowheel, atdash0/opentelemetry/injector/sitecustomize.py. This follows up on dash0hq/dash0-operator#1248 (comment): the script is now versioned, tested, and released together with the tree it bootstraps.Deployment contract
Consumers building an injectable tree (such as the operator's instrumentation image):
pip install --target <dir> dash0-opentelemetry-distro<dir>/sitecustomize.py<dir>/all-dependencies.txt(one PEP 508 requirement per line) for the dependency-conflict checkThe script stays valid Python 2.7+ so it can self-deactivate gracefully on interpreters the distribution does not support (the injector touches every Python process); it is excluded from ruff for that reason.
Deliberate deviations from the operator's copy
PYTHONPATHis split onos.pathsep(previously,) in_self_deactivate, so self-deactivation also removes the injected site for child processes whenPYTHONPATHhas multiple entries.pyproject.toml(CI enforces this), so the script enumerates theopentelemetry-*/dash0-*distributions installed there and flags overlap with the application's sites.opentelemetry-apiandopentelemetry-semantic-conventionsare excluded — applications legitimately use the API layer for manual instrumentation (preserving dash0hq/dash0-operator@ea847dcc) — and version conflicts with them are still caught by theall-dependencies.txtcheck.Version bump
The distro version bumps to 0.2.0