Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pymongo): add support for v4.9 #10718

Merged
merged 11 commits into from
Sep 23, 2024
Merged

feat(pymongo): add support for v4.9 #10718

merged 11 commits into from
Sep 23, 2024

Conversation

mabdinur
Copy link
Contributor

@mabdinur mabdinur commented Sep 19, 2024

Motivation

  • Add and test support for pymongo v4.9.1

Reproduction

pip install ddtrace==2.11.6 pymongo==4.9.1
python -c "import ddtrace; ddtrace.patch_all(pymongo=True); import pymongo"

Output

  File "dd-trace-py/ddtrace/_monkey.py", line 165, in on_import
    imported_module = importlib.import_module(path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/munirabdinur/.pyenv/versions/3.12.2/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "dd-trace-py/ddtrace/internal/module.py", line 309, in _exec_module
    self.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "dd-trace-py/ddtrace/contrib/pymongo/__init__.py", line 45, in <module>
    from .patch import get_version
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "dd-trace-py/ddtrace/internal/module.py", line 309, in _exec_module
    self.loader.exec_module(module)
  File "dd-trace-py/ddtrace/contrib/pymongo/patch.py", line 51, in <module>
    _VERIFY_VERSION_CLASS = pymongo.pool.SocketInfo if _VERSION < (4, 5) else pymongo.pool.Connection

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Copy link
Contributor

github-actions bot commented Sep 19, 2024

CODEOWNERS have been resolved as:

releasenotes/notes/pymong-4-9-support-83f7c613e5e009e6.yaml             @DataDog/apm-python
ddtrace/contrib/internal/pymongo/patch.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
riotfile.py                                                             @DataDog/apm-python
.riot/requirements/10a00e7.txt                                          @DataDog/apm-python
.riot/requirements/1424e42.txt                                          @DataDog/apm-python
.riot/requirements/14e85f3.txt                                          @DataDog/apm-python
.riot/requirements/16cae33.txt                                          @DataDog/apm-python
.riot/requirements/1ce9a99.txt                                          @DataDog/apm-python
.riot/requirements/1ed6ce0.txt                                          @DataDog/apm-python
.riot/requirements/328b28c.txt                                          @DataDog/apm-python
.riot/requirements/ad40916.txt                                          @DataDog/apm-python
.riot/requirements/b089663.txt                                          @DataDog/apm-python
.riot/requirements/b344fed.txt                                          @DataDog/apm-python
.riot/requirements/de53117.txt                                          @DataDog/apm-python
.riot/requirements/f9d0e8e.txt                                          @DataDog/apm-python

@mabdinur mabdinur added the changelog/no-changelog A changelog entry is not required for this PR. label Sep 19, 2024
@mabdinur mabdinur changed the title chore(pymongo): upgrade tests to use v4.9.1 fix(pymongo): add support for v4.9.1 Sep 19, 2024
@pr-commenter
Copy link

pr-commenter bot commented Sep 19, 2024

Benchmarks

Benchmark execution time: 2024-09-23 15:30:53

Comparing candidate commit 770c530 in PR branch munir/test-pymongo-4-9 with baseline commit 5546c23 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 356 metrics, 48 unstable metrics.

@mabdinur mabdinur marked this pull request as draft September 19, 2024 15:05
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Sep 19, 2024

Datadog Report

Branch report: munir/test-pymongo-4-9
Commit report: 770c530
Test service: dd-trace-py

✅ 0 Failed, 592 Passed, 694 Skipped, 20m 47.29s Total duration (16m 20.81s time saved)

@mabdinur mabdinur marked this pull request as ready for review September 19, 2024 17:26
@mabdinur mabdinur requested review from a team as code owners September 19, 2024 17:26
@mabdinur mabdinur changed the title fix(pymongo): add support for v4.9.1 feat(pymongo): add support for v4.9.1 Sep 19, 2024
@mabdinur
Copy link
Contributor Author

Since pymongo is a popular library it would be nice if we could sneak this change in to the v2.13.0 release @erikayasuda 🙏

@mabdinur mabdinur changed the title feat(pymongo): add support for v4.9.1 feat(pymongo): add support for v4.9 Sep 19, 2024
@erikayasuda
Copy link
Contributor

Since pymongo is a popular library it would be nice if we could sneak this change in to the v2.13.0 release @erikayasuda 🙏

I can get back to you on this 🫡

Copy link
Contributor

@erikayasuda erikayasuda left a comment

Choose a reason for hiding this comment

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

Just a nit, otherwise LGTM

riotfile.py Show resolved Hide resolved
@mabdinur mabdinur enabled auto-merge (squash) September 20, 2024 20:57
@mabdinur mabdinur merged commit a1417cb into main Sep 23, 2024
574 checks passed
@mabdinur mabdinur deleted the munir/test-pymongo-4-9 branch September 23, 2024 19:43
quinna-h added a commit that referenced this pull request Sep 23, 2024
Tests patching and unpatching pymongo, following the new changes to add
support for pymongo v4.9.1 in [feat(pymongo): add support for
v4.9](#10718)

Additionally, adds fix for an issue with `assert_wrapped` that
previously assumed wrapped object always comes from `wrapt`, when it can
come from internal wrapping function.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Munir Abdinur <munir_abdinur@hotmail.com>
Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
mabdinur added a commit that referenced this pull request Sep 25, 2024
## Motivation

- Add and test support for pymongo v4.9.1

## Reproduction

```
pip install ddtrace==2.11.6 pymongo==4.9.1
python -c "import ddtrace; ddtrace.patch_all(pymongo=True); import pymongo"
```

## Output

```
  File "dd-trace-py/ddtrace/_monkey.py", line 165, in on_import
    imported_module = importlib.import_module(path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/munirabdinur/.pyenv/versions/3.12.2/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "dd-trace-py/ddtrace/internal/module.py", line 309, in _exec_module
    self.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "dd-trace-py/ddtrace/contrib/pymongo/__init__.py", line 45, in <module>
    from .patch import get_version
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "dd-trace-py/ddtrace/internal/module.py", line 309, in _exec_module
    self.loader.exec_module(module)
  File "dd-trace-py/ddtrace/contrib/pymongo/patch.py", line 51, in <module>
    _VERIFY_VERSION_CLASS = pymongo.pool.SocketInfo if _VERSION < (4, 5) else pymongo.pool.Connection
```


## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Quinna Halim <quinna.halim@datadoghq.com>
mabdinur added a commit that referenced this pull request Sep 25, 2024
Tests patching and unpatching pymongo, following the new changes to add
support for pymongo v4.9.1 in [feat(pymongo): add support for
v4.9](#10718)

Additionally, adds fix for an issue with `assert_wrapped` that
previously assumed wrapped object always comes from `wrapt`, when it can
come from internal wrapping function.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Munir Abdinur <munir_abdinur@hotmail.com>
Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants