GraphQL Timing
Module: Magenx_GraphQlTiming · no settings, no new fields
Adds a Server-Timing header to every GraphQL response with the time Magento spent handling the request:
Server-Timing: magento-app;desc="magento dispatch";dur=42.0When a GraphQL request is slow, this tells you whether Magento or the network is the cause. With GRAPHQL_PROFILE on, the storefront’s /api/graphql proxy merges this value into the Server-Timing header the browser sees (DevTools > Network > Timing). The difference between the proxy’s proxy-upstream value and magento-app is the network hop.
The header is cheap and has no side effects, so it is safe to leave on.
User flows
Section titled “User flows”Profile a request
- A developer turns on the storefront's profiling flag.
- A browser request passes through the proxy; the back office response carries its processing time.
- The proxy merges it with its upstream time; developer tools show both. Upstream minus processing = network.
These always hold:
- The header never changes response body or status.
- One request's timing is never influenced by another.
- Duration = (end − start) × 1000, one decimal.
Edge cases
Section titled “Edge cases”| Situation | What happens |
|---|---|
| Two requests in one long-running worker. | Each header shows its own duration. |
| Processing throws an error. | Error passes on; no header. |
Out of scope
Section titled “Out of scope”- Per-operation or per-query timing.
- Timing for non-API traffic.
- Storing or exporting metrics.
Install
Section titled “Install”composer require magenxcommerce/module-graph-ql-timingbin/magento module:enable Magenx_GraphQlTimingbin/magento setup:upgradebin/magento setup:di:compile # production mode onlybin/magento cache:flush- PHP
~8.4.0||~8.5.0, Magento 2.4.8. - Source code of
Magenx_GraphQlTiming: github.com/magenxcommerce/module-graph-ql-timing
Deeper profiling
Section titled “Deeper profiling”For timing per resolver and per database query, use Magento’s built-in profiler:
bin/magento dev:profiler:enable htmlGlossary
Section titled “Glossary”| Term | Meaning |
|---|---|
| Processing time | Wall-clock time from the API request entering the back office to the response being built. |
| Server-Timing | Standard HTTP response header carrying named timing metrics. |
| Upstream time | Time the storefront proxy waited for the back office. |