Skip to content

Expose the LAMBDA_REQUEST_ID variable in PHP-FPM too - #2189

Merged
mnapoli merged 1 commit into
masterfrom
request-id-in-logs
Sep 26, 2026
Merged

mnapoli merged 1 commit into
masterfrom
request-id-in-logs

Conversation

@mnapoli

@mnapoli mnapoli commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

The function and console runtimes set LAMBDA_REQUEST_ID on every invocation (#2035), and the docs say Bref sets it on "every Lambda invocation", but PHP-FPM workers only received LAMBDA_INVOCATION_CONTEXT (JSON). This passes LAMBDA_REQUEST_ID to PHP-FPM too, so $_SERVER['LAMBDA_REQUEST_ID'] (and getenv()) works the same in every runtime. Documented in fpm-runtime.mdx. See brefphp/laravel-bridge#145 for users looking for the ID.

That lets Bref's log formatters start every line with the request ID in PHP-FPM too: brefphp/monolog-bridge#2 and brefphp/logger#12. The documentation of the logs of a single request is in #2190.

Tested on AWS with a Laravel application (PHP-FPM, Octane, queue worker, console) using this branch and the monolog-bridge branch. For a PHP-FPM request that timed out, one filter @requestId = '…' query in Logs Insights returns:

START RequestId: 092cf7a5-…
092cf7a5-…	INFO	Starting something slow	{"message":"Starting something slow","level":"INFO"}
092cf7a5-… The PHP script timed out. Bref will now restart PHP-FPM…
092cf7a5-…	Invoke Error	{"errorType":"Bref\\FpmRuntime\\FastCgi\\Timeout",…}
END RequestId: 092cf7a5-…
REPORT RequestId: 092cf7a5-…	Duration: 7056.69 ms	…

The function and console runtimes set it on every invocation, PHP-FPM workers only received
LAMBDA_INVOCATION_CONTEXT.

Claude-Session: https://claude.ai/code/session_0168N55uBK9UjfpL6r8oGjDm
@mnapoli mnapoli changed the title Pass LAMBDA_REQUEST_ID to PHP-FPM and document the logs of a single request Pass LAMBDA_REQUEST_ID to PHP-FPM Sep 26, 2026
@mnapoli mnapoli changed the title Pass LAMBDA_REQUEST_ID to PHP-FPM Expose LAMBDA_REQUEST_ID in PHP-FPM too Sep 26, 2026
@mnapoli mnapoli changed the title Expose LAMBDA_REQUEST_ID in PHP-FPM too Expose the LAMBDA_REQUEST_ID variable in PHP-FPM too Sep 26, 2026
@mnapoli
mnapoli merged commit 9313ef8 into master Sep 26, 2026
8 checks passed
@mnapoli
mnapoli deleted the request-id-in-logs branch September 26, 2026 19:12
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.

1 participant