Download prof files#2286
Conversation
for more information, see https://pre-commit.ci
…-toolbar into download-prof-files
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
This PR adds the ability to download profiling data as .prof files, addressing issue #1798. The feature is disabled by default and requires configuring the PROFILER_PROFILE_ROOT setting to specify where profile files should be saved.
Key changes:
- Added
PROFILER_PROFILE_ROOTconfiguration setting to control where profile files are saved - Implemented profile file generation in the profiling panel with signed filenames for security
- Created a new download view with URL endpoint to serve the profile files
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
debug_toolbar/settings.py |
Added PROFILER_PROFILE_ROOT default setting (None) |
debug_toolbar/panels/profiling.py |
Modified to generate and save .prof files when PROFILER_PROFILE_ROOT is configured; signs filename for secure download |
debug_toolbar/views.py |
Added download_prof_file view to handle file downloads with signature validation |
debug_toolbar/toolbar.py |
Registered new download URL endpoint |
debug_toolbar/urls.py |
Minor whitespace addition |
debug_toolbar/templates/debug_toolbar/panels/profiling.html |
Added download link UI and reformatted indentation |
debug_toolbar/static/debug_toolbar/css/toolbar.css |
Added styling for download control |
tests/panels/test_profiling.py |
Added comprehensive tests for profile file generation and download functionality |
docs/configuration.rst |
Documented the new PROFILER_PROFILE_ROOT setting |
docs/changes.rst |
Added changelog entry for the new feature |
debug_toolbar/panels/sql/tracking.py |
Unrelated changes to handle executemany parameters in SQL tracking |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hello everyone sorry for not finishing this. I have been a bit caught up working on other OSS projects . I promise to push new commits this weekend to fix the reviews co pilot left |
…-toolbar into download-prof-files
e690762 to
09f2ba0
Compare
tim-schilling
left a comment
There was a problem hiding this comment.
Thank you for continuing to work on this 🚀. I've got some questions about the direction of this. If you're confused, or think I may be wrong, please let me know. I'm happy to hop on a call and chat about this too!
|
|
||
| root_func = cProfile.label(super().process_request.__code__) | ||
| profile_root = dt_settings.get_config()["PROFILER_PROFILE_ROOT"] | ||
| storage = FileSystemStorage(location=profile_root) |
There was a problem hiding this comment.
Could we use django.core.files.storage.default_storage instead of instantiating a new one?
There was a problem hiding this comment.
Are we going in the wrong direction here trying to write actual files to the server? Couldn't we just store the file's content with the panel, then render that out like a file in download_prof_file?
Sorry to shift our direction again, but something isn't sitting right with me. What do you think? I'd love to know if you feel the same.
There was a problem hiding this comment.
I have a question i assume by storing the files content in the panel this would be ephemeral right? If we dont need persistence we could do that
There was a problem hiding this comment.
Yes, they would be. Unless of course they are using the DatabaseStore.
There was a problem hiding this comment.
The database store also prunes old records. We have no guarantees regarding the contents of debug logs for now, for example across version upgrades. At least that's my understanding
Description
This pr is based on the work of @andoriyaprashant which he made to fix #1798. I am continuing his work to get it over the finish line. His pr is this #2146 .
Fixes #1798
Checklist:
docs/changes.rst.