Skip to content

Conversation

@JohananOppongAmoateng
Copy link
Contributor

@JohananOppongAmoateng JohananOppongAmoateng commented Dec 17, 2025

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:

  • I have added the relevant tests for this change.
  • I have added an item to the Pending section of docs/changes.rst.

@github-actions
Copy link

github-actions bot commented Dec 17, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  debug_toolbar
  toolbar.py
  urls.py
  views.py 44
  debug_toolbar/panels
  profiling.py 199
Project Total  

This report was generated by python-coverage-comment-action

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ROOT configuration 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.

@JohananOppongAmoateng
Copy link
Contributor Author

JohananOppongAmoateng commented Jan 12, 2026

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

Copy link
Member

@tim-schilling tim-schilling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use django.core.files.storage.default_storage instead of instantiating a new one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.

Download profiling results

3 participants