Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tracing): fix logic for setting
in_app
flag
Previously, in case packages added in `in_app_include` were installed into a location outside of the project root directory, stack frames from those packages were not marked as `in_app`. Cases include running Python from virtualenv, created outside of the project root directory, or Python packages installed into the system using package managers. This resulted in inconsistency: traces from the same project would have different `in_app` flags depending on the deployment method. Steps to reproduce (virtualenv outside of project root): ``` $ docker run --replace --rm --name sentry-postgres -e POSTGRES_USER=sentry -e POSTGRES_PASSWORD=sentry -d -p 5432:5432 postgres $ distrobox create -i ubuntu:24.04 -n sentry-test-in_app_include-venv $ distrobox enter sentry-test-in_app_include-venv $ python3 -m venv /tmp/.venv-test-in_app_include $ source /tmp/.venv-test-in_app_include/bin/activate $ pytest tests/integrations/django/test_db_query_data.py::test_query_source_with_in_app_include # FAIL ``` Steps to reproduce (system packages): ``` $ docker run --replace --rm --name sentry-postgres -e POSTGRES_USER=sentry -e POSTGRES_PASSWORD=sentry -d -p 5432:5432 postgres $ distrobox create -i ubuntu:24.04 -n sentry-test-in_app_include-os $ distrobox enter sentry-test-in_app_include-os $ sudo apt install python3-django python3-pytest python3-pytest-cov python3-pytest-django python3-jsonschema python3-urllib3 python3-certifi python3-werkzeug python3-psycopg2 $ pytest tests/integrations/django/test_db_query_data.py::test_query_source_with_in_app_include # FAIL ``` In this change, the logic was slightly changed to avoid these discrepancies and conform to the requirements, described in the PR with `in_app` flag introduction: getsentry#1894 (comment). Note that the `_module_in_list` function returns `False` if `name` is `None`, hence extra check before function call can be omitted to simplify code.
- Loading branch information