Skip to content

Add API Gateway request timestamp to server variables #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 10, 2025

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