Repository navigation
feat(logging): add request duration to log records - #867
Open
josephfusco wants to merge 4 commits into
Open
josephfusco wants to merge 4 commits into
josephfusco wants to merge 4 commits into
Conversation
Time the WPGraphQL request lifecycle from the earliest hook (graphql_request_data, falling back to do_graphql_request) until graphql_after_execute. A new RequestDurationProcessor adds the elapsed milliseconds to every record's extra data as request_duration_ms, and the response events add the total to their context so EventManager subscribers receive it.
…nst leaks Start timing HTTP requests at graphql_process_http_request (before the WPGraphQL Request exists) and clear all timer state there and on graphql_process_http_request_response, so a request that throws before graphql_after_execute cannot leak its timer into later records. graphql_request_data no longer restarts a timer that is already pending. Accept any value in the graphql_request_data callback and fall back to microtime() if hrtime() is unavailable, so the timer can never break a GraphQL request.
…helper Assert QueryEventLifecycle registers the timer hooks, and test an internal batched graphql() call and LoggingHelper::add_request_duration. Fix two psalm errors: use a float literal in the microtime() fallback so the multiplication is not mixed int/float, and register the graphql_request_data filter by its literal name so psalm's hook checks stop flagging DataDeletionScheduler's action.
Document request_duration_ms, where the timer starts and stops, and how batches and nested graphql() calls behave, in the plugin docs and readme.txt. Use a single RequestTimer::DURATION_KEY for the extra and context key instead of a processor constant plus a string literal, and drop RequestTimer::is_running(), which only the tests used.
Contributor
📦 Plugin Artifacts Ready!Download from GitHub Actions run Available plugins:
See the "Artifacts" section at the bottom of the Actions run page |
josephfusco
marked this pull request as ready for review
October 30, 2026 19:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
request_duration_msto every log record written during a WPGraphQL request, with the request total on the response events.Closes #443
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Assisting with adding request duration to log context.