-
Notifications
You must be signed in to change notification settings - Fork 426
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
fix(iast): add code to filter out ddtrace stuff from dir() on patched modules #11490
Conversation
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
|
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
BenchmarksBenchmark execution time: 2024-11-22 13:00:35 Comparing candidate commit 7d3dbd2 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 388 metrics, 2 unstable metrics. |
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
Signed-off-by: Juanjo Alvarez <[email protected]>
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.15 2.15
# Navigate to the new working tree
cd .worktrees/backport-2.15
# Create a new branch
git switch --create backport-11490-to-2.15
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a9a6ad712e37e832d0e43a0c9bf6541f7bded8d4
# Push it to GitHub
git push --set-upstream origin backport-11490-to-2.15
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.15 Then, create a pull request where the |
… modules (#11490) Signed-off-by: Juanjo Alvarez <[email protected]> ## Description While testing on dd-source CI we found an issue where a module was doing a `dir(other_module)` and the changed results from the patched module were breaking stuff (because our patching would add `ddtrace_aspects`, `ddtrace_sink_points`, et cetera to the results and the original module was expecting all `other_module` symbols to have some members like `id`). This PRs fixes this problem by: - Creating a custom `__dir__` function (that will override any pre-existing ones) removing from the results all the symbols that we add ourselves while patching. - Renaming all added `ddtrace` symbols to `__ddtrace`. Also: - Adds a `_DD_IAST_NO_DIR_PATCH` config var to disable the wrapping of the patched module `__dir__` functions in case the user have some side-effect problem. - The return type of `visit_ast` has been fixed (it wrongly was `str` while is in fact a `ast.Module` type). ## 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) --------- Signed-off-by: Juanjo Alvarez <[email protected]> (cherry picked from commit a9a6ad7)
… modules (#11490) Signed-off-by: Juanjo Alvarez <[email protected]> ## Description While testing on dd-source CI we found an issue where a module was doing a `dir(other_module)` and the changed results from the patched module were breaking stuff (because our patching would add `ddtrace_aspects`, `ddtrace_sink_points`, et cetera to the results and the original module was expecting all `other_module` symbols to have some members like `id`). This PRs fixes this problem by: - Creating a custom `__dir__` function (that will override any pre-existing ones) removing from the results all the symbols that we add ourselves while patching. - Renaming all added `ddtrace` symbols to `__ddtrace`. Also: - Adds a `_DD_IAST_NO_DIR_PATCH` config var to disable the wrapping of the patched module `__dir__` functions in case the user have some side-effect problem. - The return type of `visit_ast` has been fixed (it wrongly was `str` while is in fact a `ast.Module` type). ## 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) --------- Signed-off-by: Juanjo Alvarez <[email protected]> (cherry picked from commit a9a6ad7)
… modules (#11490) Signed-off-by: Juanjo Alvarez <[email protected]> While testing on dd-source CI we found an issue where a module was doing a `dir(other_module)` and the changed results from the patched module were breaking stuff (because our patching would add `ddtrace_aspects`, `ddtrace_sink_points`, et cetera to the results and the original module was expecting all `other_module` symbols to have some members like `id`). This PRs fixes this problem by: - Creating a custom `__dir__` function (that will override any pre-existing ones) removing from the results all the symbols that we add ourselves while patching. - Renaming all added `ddtrace` symbols to `__ddtrace`. Also: - Adds a `_DD_IAST_NO_DIR_PATCH` config var to disable the wrapping of the patched module `__dir__` functions in case the user have some side-effect problem. - The return type of `visit_ast` has been fixed (it wrongly was `str` while is in fact a `ast.Module` type). - [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) --------- Signed-off-by: Juanjo Alvarez <[email protected]> (cherry picked from commit a9a6ad7)
… modules [backport 2.17] (#11504) Backport a9a6ad7 from #11490 to 2.17. Signed-off-by: Juanjo Alvarez <[email protected]> ## Description While testing on dd-source CI we found an issue where a module was doing a `dir(other_module)` and the changed results from the patched module were breaking stuff (because our patching would add `ddtrace_aspects`, `ddtrace_sink_points`, et cetera to the results and the original module was expecting all `other_module` symbols to have some members like `id`). This PRs fixes this problem by: - Creating a custom `__dir__` function (that will override any pre-existing ones) removing from the results all the symbols that we add ourselves while patching. - Renaming all added `ddtrace` symbols to `__ddtrace`. Also: - Adds a `_DD_IAST_NO_DIR_PATCH` config var to disable the wrapping of the patched module `__dir__` functions in case the user have some side-effect problem. - The return type of `visit_ast` has been fixed (it wrongly was `str` while is in fact a `ast.Module` type). ## 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: Juanjo Alvarez Martinez <[email protected]>
… modules [backport 2.15] (#11521) Backport a9a6ad7 from #11490 to 2.15. Signed-off-by: Juanjo Alvarez [[email protected]](mailto:[email protected]) ## Description While testing on dd-source CI we found an issue where a module was doing a dir(other_module) and the changed results from the patched module were breaking stuff (because our patching would add ddtrace_aspects, ddtrace_sink_points, et cetera to the results and the original module was expecting all other_module symbols to have some members like id). This PRs fixes this problem by: Creating a custom __dir__ function (that will override any pre-existing ones) removing from the results all the symbols that we add ourselves while patching. Renaming all added ddtrace symbols to __ddtrace. Also: Adds a _DD_IAST_NO_DIR_PATCH config var to disable the wrapping of the patched module __dir__ functions in case the user have some side-effect problem. The return type of visit_ast has been fixed (it wrongly was str while is in fact a ast.Module type). ## 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) --------- Signed-off-by: Juanjo Alvarez <[email protected]>
… modules [backport 2.16] (#11503) Backport a9a6ad7 from #11490 to 2.16. Signed-off-by: Juanjo Alvarez <[email protected]> ## Description While testing on dd-source CI we found an issue where a module was doing a `dir(other_module)` and the changed results from the patched module were breaking stuff (because our patching would add `ddtrace_aspects`, `ddtrace_sink_points`, et cetera to the results and the original module was expecting all `other_module` symbols to have some members like `id`). This PRs fixes this problem by: - Creating a custom `__dir__` function (that will override any pre-existing ones) removing from the results all the symbols that we add ourselves while patching. - Renaming all added `ddtrace` symbols to `__ddtrace`. Also: - Adds a `_DD_IAST_NO_DIR_PATCH` config var to disable the wrapping of the patched module `__dir__` functions in case the user have some side-effect problem. - The return type of `visit_ast` has been fixed (it wrongly was `str` while is in fact a `ast.Module` type). ## 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: Juanjo Alvarez Martinez <[email protected]>
Signed-off-by: Juanjo Alvarez [email protected]
Description
While testing on dd-source CI we found an issue where a module was doing a
dir(other_module)
and the changed results from the patched module were breaking stuff (because our patching would addddtrace_aspects
,ddtrace_sink_points
, et cetera to the results and the original module was expecting allother_module
symbols to have some members likeid
).This PRs fixes this problem by:
__dir__
function (that will override any pre-existing ones) removing from the results all the symbols that we add ourselves while patching.ddtrace
symbols to__ddtrace
.Also:
_DD_IAST_NO_DIR_PATCH
config var to disable the wrapping of the patched module__dir__
functions in case the user have some side-effect problem.visit_ast
has been fixed (it wrongly wasstr
while is in fact aast.Module
type).Checklist
Reviewer Checklist