-
Notifications
You must be signed in to change notification settings - Fork 11
Remove current path from the module path in ProfileEncoder. #35
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
Conversation
Running the uwsgi sample application with Python 3.8.10-3.9.2 showed incorrect module path in the UI. This was narrowed down to traceback returning different results (a path with "/."). This change makes sure the path is not leaked out.
PapaPedro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just a few comments/questions
| def _remove_prefix_path(module_path, sys_paths): | ||
| current_path = str(Path().absolute()) | ||
| if current_path in module_path: | ||
| return module_path.replace(current_path, "").replace("/.", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not replace "/./" by "/" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also that would not work in windows because the "/" would have been replaced already right? Are we sure we cannot have that problem in windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds better to replace /./, I'll update. I didn't test anything on windows. The existing unit tests with Windows passed, but I didn't add anything new.
| # When running the sample app with uwsgi for Python 3.8.10-3.9.2, the traceback command | ||
| # returns a file path that contains "/.". | ||
| # To not let the path go into the module name, we are removing it later in the ProfileEncoder. | ||
| # Examples: | ||
| # - file '/Users/mirelap/Documents/workspace/JSON/aws-codeguru-profiler-python-demo-application/sample-demo-django-app/./polls/views.py', line 104, code get_queryset>, 104 | ||
| # - file '/Users/mirelap/Documents/workspace/JSON/aws-codeguru-profiler-python-demo-application/sample-demo-django-app/polls/views.py', line 104, code get_queryset>, 104 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment seems to be very specific about the /./ problem but is not next to the code that actually fixes this issue, should we not simply add a comment here saying only that the full path will be removed from frame names later in the encoder and only talk about the /./ issue when we do the replace about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll update.
Running the uwsgi sample application with Python 3.8.10-3.9.2 showed incorrect module path in the UI.
This was narrowed down to
tracebackreturning different results (a path with "/.").This change makes sure the path is not leaked out.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Issue #, if available:
Description of changes:
Testing:
With this change, this is the logged module after removing the prefix :
INFO /polls/views.py--
uwsgi:/Users/mirelap/Documents/workspace/JSON/aws-codeguru-profiler-python-demo-application/sample-demo-django-app//polls/viewspy--
runserver:/polls/views.pyBefore this change when running this sample app with uwsgi command (not with the local runserver) starting Python 3.8.10:
.
After this change: