-
Notifications
You must be signed in to change notification settings - Fork 428
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
Cannot run pytest-cov with ddtrace installed in the same project #11256
Comments
Thanks for the report, @ddarricau . We're winning the race to @vitor-de-araujo or I should refactor the code so that we only call |
Great thank you ! |
Hello could we get an update on when you might look at this ? |
Hi @vitor-de-araujo any progress in this issue? We're also affected by it, not being able to use sysmon coverage is a bummer. It slows down test collection in a large test suite a whooping 200%. Thank you |
On Python 3.12+, CI Visibility / Test Optimization uses `sys.monitoring` to gather code coverage information. The problem is that if other tools, such as `pyest-cov`, also try to register a `sys.monitoring` tool for coverage, an exception will be raised because Python only allows one handler per tool type (see issue #11256). This PR postpones tool registering until the first call to `instrument_all_lines()`, giving other tools the opportunity to register themselves; in this case, however, we do not gather code coverage information. ## 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)
Hi, @pablogamboa and @ddarricau! I have just merged a PR to fix this. It should come out in the next ddtrace releases, within the next couple of weeks. Sorry for the delay in addressing this issue! |
On Python 3.12+, CI Visibility / Test Optimization uses `sys.monitoring` to gather code coverage information. The problem is that if other tools, such as `pyest-cov`, also try to register a `sys.monitoring` tool for coverage, an exception will be raised because Python only allows one handler per tool type (see issue #11256). This PR postpones tool registering until the first call to `instrument_all_lines()`, giving other tools the opportunity to register themselves; in this case, however, we do not gather code coverage information. - [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)) - [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) (cherry picked from commit 7074375)
On Python 3.12+, CI Visibility / Test Optimization uses `sys.monitoring` to gather code coverage information. The problem is that if other tools, such as `pyest-cov`, also try to register a `sys.monitoring` tool for coverage, an exception will be raised because Python only allows one handler per tool type (see issue #11256). This PR postpones tool registering until the first call to `instrument_all_lines()`, giving other tools the opportunity to register themselves; in this case, however, we do not gather code coverage information. - [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)) - [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) (cherry picked from commit 7074375)
On Python 3.12+, CI Visibility / Test Optimization uses `sys.monitoring` to gather code coverage information. The problem is that if other tools, such as `pyest-cov`, also try to register a `sys.monitoring` tool for coverage, an exception will be raised because Python only allows one handler per tool type (see issue #11256). This PR postpones tool registering until the first call to `instrument_all_lines()`, giving other tools the opportunity to register themselves; in this case, however, we do not gather code coverage information. - [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)) - [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) (cherry picked from commit 7074375)
amazing news thanks @vitor-de-araujo ❤ |
…port 3.0] (#12577) Backport 7074375 from #12558 to 3.0. On Python 3.12+, CI Visibility / Test Optimization uses `sys.monitoring` to gather code coverage information. The problem is that if other tools, such as `pyest-cov`, also try to register a `sys.monitoring` tool for coverage, an exception will be raised because Python only allows one handler per tool type (see issue #11256). This PR postpones tool registering until the first call to `instrument_all_lines()`, giving other tools the opportunity to register themselves; in this case, however, we do not gather code coverage information. - [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)) - [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) (cherry picked from commit 7074375) Co-authored-by: Federico Mon <[email protected]>
…port 3.1] (#12579) Backport 7074375 from #12558 to 3.1. On Python 3.12+, CI Visibility / Test Optimization uses `sys.monitoring` to gather code coverage information. The problem is that if other tools, such as `pyest-cov`, also try to register a `sys.monitoring` tool for coverage, an exception will be raised because Python only allows one handler per tool type (see issue #11256). This PR postpones tool registering until the first call to `instrument_all_lines()`, giving other tools the opportunity to register themselves; in this case, however, we do not gather code coverage information. - [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)) - [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) (cherry picked from commit 7074375) Co-authored-by: Federico Mon <[email protected]>
…port 2.21] (#12578) Backport 7074375 from #12558 to 2.21. On Python 3.12+, CI Visibility / Test Optimization uses `sys.monitoring` to gather code coverage information. The problem is that if other tools, such as `pyest-cov`, also try to register a `sys.monitoring` tool for coverage, an exception will be raised because Python only allows one handler per tool type (see issue #11256). This PR postpones tool registering until the first call to `instrument_all_lines()`, giving other tools the opportunity to register themselves; in this case, however, we do not gather code coverage information. - [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)) - [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) (cherry picked from commit 7074375)
The fix is available in ddtrace >=3.2.0 and also has been backported to 2.21.4. I'm closing this issue, but let me know if you run into any issues. |
Summary
Basically I am unable to run test coverage on a project that includes both ddtrace and pytest-cov
Expected vs actual result
I should be able to do so
Reproducer
In order to reproduce I have a very simple project with
And a test file
Whenever I run the command
COVERAGE_FILE=foo COVERAGE_CORE=sysmon pytest --cov=. tests/test_ddtrace_coverage.py
I get the following errorNote that this only happens when using the
COVERAGE_CORE=sysmon
flag, it seems that both ddtrace and pytest-cov request the same tool_id in that module. Note that using this flag is important to me as it significantly shortens the CI run time at my job.I am not sure who should resolve the issue so I am also posting an issue on the pytest-cov repo.
Also not that if I use a ddtrace version <
2.12.0
it works fine.The text was updated successfully, but these errors were encountered: