Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

  • Understand existing HTTP request tracking in Profiler.php
  • Create new requests() method in Command.php to display HTTP request metrics
  • Add support for a new profiler type 'request' to track individual HTTP requests
  • Update Profiler class to track individual HTTP request details (URL, method, time, status)
  • Add tests for the new wp profile requests command
  • Update composer.json to register the new command
  • Update test to include requests command in usage output
  • Optimize profiler to not add unnecessary hooks for request profiling
  • Fix hook parameter signatures to match WordPress
  • Run code review and address feedback
  • Run security checks
  • Improve test with mu-plugin that makes actual HTTP requests
  • Add HTTP mocking to prevent real HTTP requests in tests
  • Handle preempted HTTP requests by resetting tracking properties
  • Fix handling of preempted/mocked requests
  • Fix PHP warning for non-numeric fields in Formatter

Bug Fix

Fixed PHP warning "A non-numeric value encountered" by checking if values are numeric before attempting to sum them in Formatter.php. String fields like 'method', 'url', and 'status' are now properly skipped when calculating totals.

Original prompt

This section details on the original issue you should resolve

<issue_title>Introduce wp profile requests</issue_title>
<issue_description>It would be helpful to be able to see all requests and how much time they're taking.</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber The idea is to create a `wp profile requests` command that would minor execution time, etc. for all HTTP requests made during the WordPress load process.

Here's where we're already hooking into the HTTP request process to observe timing:

WP_CLI::add_wp_hook( 'pre_http_request', array( $this, 'wp_request_begin' ) );
WP_CLI::add_wp_hook( 'http_api_debug', array( $this, 'wp_request_end' ) );
</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits November 7, 2025 12:23
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>
Copilot AI changed the title [WIP] Add wp profile requests command for monitoring HTTP request timing Add wp profile requests command to monitor HTTP requests Nov 7, 2025
Copilot AI requested a review from swissspidy November 7, 2025 12:33
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 72.13115% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Profiler.php 63.82% 17 Missing ⚠️

📢 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>

This comment was marked as resolved.

swissspidy and others added 2 commits November 10, 2025 22:16
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>
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy
Copy link
Member

@copilot but those parameters are all unused, that can't be it. please check again

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce wp profile requests

2 participants