-
Notifications
You must be signed in to change notification settings - Fork 30
Add wp profile requests command to monitor HTTP requests
#206
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
wp profile requests command to monitor HTTP requests
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
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.
Pull Request Overview
This PR introduces a new wp profile requests command to monitor and display HTTP requests made during WordPress load, including their method, URL, status code, and execution time.
Key changes:
- Added
requests()method to Command.php with standard profiling options - Enhanced Profiler.php to capture and log individual HTTP request details
- Registered the new command in composer.json and added comprehensive test coverage
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Command.php | Implements the requests subcommand with standard formatting and ordering options |
| src/Profiler.php | Adds request tracking properties and enhances HTTP hook handlers to capture request details and timing |
| composer.json | Registers the new profile requests command |
| features/profile-requests.feature | Adds test scenarios for HTTP request profiling with mocked responses |
| features/profile.feature | Updates usage documentation to include the new requests command |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Implements
wp profile requeststo display all HTTP requests made during WordPress load, showing method, URL, status code, and execution time for each request.Changes
Command.php
requests()method with standard profiling options (--url, --fields, --format, --order, --orderby)Profiler.php
$request_start_timeand$request_argsproperties to track individual requestswp_request_begin()to capture request details (URL, method) when type='request'wp_request_end()to create Logger entries with timing and status from response$preempt, $parsed_args, $urlfor pre_http_request;$response, $context, $class, $parsed_args, $urlfor http_api_debug)$parsed_argsto prevent PHP warningspre_http_requestfilter returns early andhttp_api_debugdoesn't fire)composer.json
profile requestscommandTests
features/profile-requests.featurewith test scenarios including a mu-plugin that makes HTTP requests with HTTP response mocking to prevent actual external requestsfeatures/profile.featureusage outputExample
Fixes #129
Original prompt
wp profile requests#129💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.