open-telemetry / open-telemetry/opentelemetry-python-contrib
Remove `packaging` as a runtime dependency of `opentelemetry-instrumentation-sqlalchemy`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Remove packaging as a runtime dependency of opentelemetry-instrumentation-sqlalchemy
Summary
opentelemetry-instrumentation-sqlalchemy declares packaging >= 21.0 as a
runtime dependency, used solely to compare the installed SQLAlchemy version.
Motivation: the auto-instrumentation injector
The auto-instrumentation injector (the Python auto-instrumentation shipped by the
OpenTelemetry Operator) bundles the instrumentation packages and all of their
runtime dependencies into an init container and prepends that directory to the
target application's PYTHONPATH. Every runtime dependency is therefore injected
into the user's application process, where a common library like packaging
risks version shadowing/conflicts and adds to the injected payload. Removing it
shrinks that footprint. See #4882 for the full rationale.
Where it is used
pyproject.toml:packaging >= 21.0independencies.src/opentelemetry/instrumentation/sqlalchemy/__init__.py:241(and 258, 299,
302):parse_version(sqlalchemy.__version__).release >= (1, 4).
Purpose: spec-compliant PEP 440 parsing of sqlalchemy.__version__ to branch
behavior by installed SQLAlchemy version.
Proposed resolution
Import the PEP 440 Version from the internal implementation added in #4882
(opentelemetry.instrumentation._packaging.version) instead of packaging, and
remove packaging from this package's dependencies.
Depends on #4882, which introduces opentelemetry.instrumentation._packaging
in opentelemetry-instrumentation (a dependency of this package).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with #4882 and the internal implementation under opentelemetry.instrumentation._packaging, then inspect pyproject.toml and the version checks at lines 241, 258, 299, and 302 of src/opentelemetry/instrumentation/sqlalchemy/init.py. Replace the runtime dependency and preserve the SQLAlchemy version branching, then run the package tests and verify packaging is no longer declared at runtime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- databases, observability
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100