In my Laravel app, I want to add the job execution time to each job's log. To do this I am subtracting LARAVEL_START
from the current microtime()
like this:
$data['meta']['requestDuration'] = round((microtime(true) - LARAVEL_START) * 1000, 2);
While working on it, I only ran one queue worker with php artisan queue:listen
, which gave me the expected result of about 450ms.
Running the same code in production with, for example, five queue workers results in times stored, such as 19517ms. I also noticed that depending on how long the workers run, the time is increased as well.