TimingMiddleware
Records timing spans for downstream middleware execution.
Synopsis
Section titled “Synopsis”class TimingMiddleware implements MiddlewareInterface
| Implements | MiddlewareInterface |
| Source | Middleware/TimingMiddleware.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(bool $emitHeader = false, ClockInterface $clock = new SystemClock(…)): mixed
| Parameter | Type | Description |
|---|---|---|
$emitHeader | bool | |
$clock | ClockInterface |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | Measures total pipeline time into the request’s ExecutionState metrics. |
process()
Section titled “process()”public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
Measures total pipeline time into the request’s ExecutionState metrics.
Runs at the head of the bootstrap phase so the measurement spans essentially the whole stack. Reuses the ExecutionState already on the request, or creates one and attaches it, then writes total_ms into its metrics after the downstream handler returns. The X-Quiote-Timing header is added only when the constructor enabled it, and is skipped without complaint if the metrics cannot be JSON-encoded.
| Parameter | Type | Description |
|---|---|---|
$request | ServerRequestInterface | |
$handler | RequestHandlerInterface |
Returns ResponseInterface