Skip to content

Add support for wrapt 2.x#4203

Open
blarghmatey wants to merge 1 commit intoopen-telemetry:mainfrom
mitodl:wrapt-2.0-support
Open

Add support for wrapt 2.x#4203
blarghmatey wants to merge 1 commit intoopen-telemetry:mainfrom
mitodl:wrapt-2.0-support

Conversation

@blarghmatey
Copy link

Description

This PR adds support for wrapt 2.x while maintaining backward compatibility with wrapt 1.x.

Key Changes

Version Constraints

  • Updated wrapt version constraint from >=1.0.0, <2.0.0 to >=1.0.0 in:
    • opentelemetry-instrumentation
    • opentelemetry-processor-baggage
    • 22 instrumentation packages

Code Changes

  • Replaced ObjectProxy with BaseObjectProxy where iteration support is not needed
  • Added fallback import for wrapt 1.x compatibility: from wrapt import ObjectProxy as BaseObjectProxy
  • Kept ObjectProxy usage in classes that implement __iter__() (botocore, aiopg)

Background

In wrapt 2.0, the class hierarchy changed:

  • wrapt 1.x: ObjectProxy was the base class
  • wrapt 2.x: BaseObjectProxy is now the base class, ObjectProxy is a subclass that adds __iter__() support

This change uses BaseObjectProxy directly where iteration is not needed, providing better compatibility and avoiding unnecessary overhead. The fallback import ensures compatibility with wrapt 1.x.

Files that keep using ObjectProxy

  • instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py - implements __iter__()
  • instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py - implements __aiter__()

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Changes maintain backward compatibility with wrapt 1.x
  • The fallback import pattern ensures BaseObjectProxy falls back to ObjectProxy on wrapt 1.x

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added (existing tests should validate compatibility)
  • Documentation has been updated (not required for dependency version bump)

Fixes #3903
Supersedes #3930
Supersedes #4082

@blarghmatey blarghmatey requested a review from a team as a code owner February 13, 2026 15:44
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 13, 2026

CLA Not Signed

- Update wrapt version constraint from '>=1.0.0, <2.0.0' to '>=1.0.0' in all affected packages
- Replace ObjectProxy with BaseObjectProxy where iteration support is not needed
- Add fallback import for wrapt 1.x compatibility (ObjectProxy as BaseObjectProxy)
- Keep ObjectProxy usage in classes that implement __iter__ (botocore, aiopg)
- Update CHANGELOG.md

This change maintains backward compatibility with wrapt 1.x while enabling
support for wrapt 2.x. BaseObjectProxy is the new base class in wrapt 2.x,
while ObjectProxy is now a subclass that adds __iter__() support.

Fixes open-telemetry#3903
Related to open-telemetry#3930 and open-telemetry#4082
@blarghmatey
Copy link
Author

I believe I signed the CLA properly. I'm not sure if there's something needed to get the check to re-evaluate.

@xrmx
Copy link
Contributor

xrmx commented Feb 16, 2026

We need to test users of ObjectProxy with wrapt>=2,<3 per #3930 (comment)

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.

Support wrapt 2.0 in pyproject.toml

4 participants