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

fix: make sure functions can be excluded #263

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

apotterri
Copy link
Collaborator

Changes in 68ff82e meant that it was no longer possible to exclude a function by name. These changes make it work again.

Fixes #262.

@petecheslock
Copy link
Contributor

I set this in my requirements.txt

appmap @ git+https://github.com/getappmap/appmap-python@excludes_20231025

My appmap.yml

appmap_dir: tmp/appmap
language: python
name: django-oscar
packages:
  - path: oscar.apps.catalogue.abstract_models
    exclude: 
    - AbstractCategory.get_ancestors_and_self

and pip installed

pip install -r requirements.txt                            ✔  6s   3.9.18   django-oscar   07:54:48  
Collecting appmap@ git+https://github.com/getappmap/appmap-python@excludes_20231025 (from -r requirements.txt (line 1))
  Cloning https://github.com/getappmap/appmap-python (to revision excludes_20231025) to /private/var/folders/2y/t_jpbzqd07l4969l1523q2y40000gn/T/pip-install-s4h1ado0/appmap_764a6c0d91f2487fa946f053ea95226e
  Running command git clone --filter=blob:none --quiet https://github.com/getappmap/appmap-python /private/var/folders/2y/t_jpbzqd07l4969l1523q2y40000gn/T/pip-install-s4h1ado0/appmap_764a6c0d91f2487fa946f053ea95226e
  Running command git checkout -b excludes_20231025 --track origin/excludes_20231025
  Switched to a new branch 'excludes_20231025'
  branch 'excludes_20231025' set up to track 'origin/excludes_20231025' by rebasing.
  Resolved https://github.com/getappmap/appmap-python to commit 9a8167dc96450243d073c932400b1a07c6d58f04
  Running command git submodule update --init --recursive -q
  Installing build dependencies ... done
Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: appmap
  Building wheel for appmap (pyproject.toml) ... done
  Created wheel for appmap: filename=appmap-1.17.0-py3-none-any.whl size=130459 sha256=021971bcfe1df3636ca8b676106c86770e0104a69fb8b6ea389a275ee51c646e
  Stored in directory: /private/var/folders/2y/t_jpbzqd07l4969l1523q2y40000gn/T/pip-ephem-wheel-cache-0ei8nljy/wheels/0b/b7/35/61df0c41c6788dfe16b57421186424b052e41c7e02c523bf2b
Successfully built appmap
Installing collected packages: appmap
Successfully installed appmap-1.17.0

ran this:

APPMAP_LOG_LEVEL=debug pytest -svv tests/integration/catalogue/test_category.py::TestCategory::test_includes_parents_name_in_full_name >& appmap.log

The subsequent appmap details when running the stats command

 appmap stats -a '/Users/petecheslock/repos/django-oscar/tmp/appmap/pytest/tests_integration_catalogue_test_cate
gory_TestCategory_test_includes_parents_name_in_full_name.appmap.json'
Analyzing AppMap: /Users/petecheslock/repos/django-oscar/tmp/appmap/pytest/tests_integration_catalogue_test_category_TestCategory_test_includes_parents_name_in_full_name.appmap.json

i.e. nothing.

If I run this again on the old version of appmap-python i would get the following.

appmap stats -a '/Users/petecheslock/repos/django-oscar/tmp/appmap/pytest/tests_integration_catalogue_test_category_TestCategory_test_includes_parents_name_in_full_name.appmap.json'
Analyzing AppMap: /Users/petecheslock/repos/django-oscar/tmp/appmap/pytest/tests_integration_catalogue_test_category_TestCategory_test_includes_parents_name_in_full_name.appmap.json

1. function:oscar/apps/catalogue/abstract_models/AbstractCategory#get_ancestors_and_self
      count: 2016
      estimated size: 748.0 KB
      

So looks like this is working for me now.

@apotterri
Copy link
Collaborator Author

Great, @petecheslock, thanks for checking this out.

With this config, only functions in the module oscar.apps.catalogue.abstract_models are going to get instrumented (except for AbstractCategory.get_ancestors_and_self, of course).

If you'd like to have other functions instrumented as well, try this config:

appmap_dir: tmp/appmap
language: python
name: django-oscar
packages:
  - path: oscar
    exclude: 
    - apps.catalogue.abstract_models.AbstractCategory.get_ancestors_and_self

which is, admittedly, a little awkward.

I'd really been hoping to support a config like

appmap_dir: tmp/appmap
language: python
name: django-oscar
packages:
  - path: oscar.apps.catalogue.abstract_models
    exclude: 
    - AbstractCategory.get_ancestors_and_self
  - path: oscar

where the order of the paths is significant. But, for now, we're stuck with the awkward one.

@petecheslock
Copy link
Contributor

Ah great! I was experimenting with the later config seeing if that would do what I needed but I'll use the top one to instrument the rest of the packages and give this a try now.

_appmap/importer.py Outdated Show resolved Hide resolved
Changes in 68ff82e meant that it was no longer possible to exclude a
function by name. These changes make it work again.
@apotterri apotterri merged commit d2b4ed5 into master Oct 27, 2023
1 check passed
@apotterri apotterri deleted the excludes_20231025 branch October 27, 2023 19:56
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.

Can't exclude functions from AppMaps
3 participants