Skip to content

Add API Gateway request timestamp to server variables#192

Merged
taylorotwell merged 3 commits intolaravel:2.0from
mortenhauberg:2.0
Jul 10, 2025
Merged

Add API Gateway request timestamp to server variables#192
taylorotwell merged 3 commits intolaravel:2.0from
mortenhauberg:2.0

Conversation

@mortenhauberg
Copy link
Contributor

This PR adds support for extracting the original request timestamp from the API Gateway event (requestContext.requestTimeEpoch or requestContext.timeEpoch) and exposes it in the $_SERVER array as AWS_API_GATEWAY_REQUEST_TIME.

This enables more accurate request duration tracking and allows downstream code to calculate cold start latency by comparing the API Gateway arrival time to actual execution time.

The timestamp is derived directly from the incoming event and kept within the request context rather than being set as a global environment variable. This keeps the data scoped to the request lifecycle and avoids side effects across concurrent executions.

If preferred, I’m happy to revise this to expose it via an environment variable or another mechanism.

This PR adds support for extracting the original request timestamp from the API Gateway event (`requestContext.requestTimeEpoch` or `requestContext.timeEpoch`) and exposes it in the `$_SERVER` array as `AWS_API_GATEWAY_REQUEST_TIME`.

This enables more accurate request duration tracking and allows downstream code to calculate cold start latency by comparing the API Gateway arrival time to actual execution time.

The timestamp is derived directly from the incoming event and kept within the request context rather than being set as a global environment variable.
This keeps the data scoped to the request lifecycle and avoids side effects across concurrent executions.

If preferred, I’m happy to revise this to expose it via an environment variable or another mechanism.
@jbrooksuk jbrooksuk requested a review from themsaid July 9, 2025 10:42
@taylorotwell taylorotwell merged commit 73d862a into laravel:2.0 Jul 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants