Laravel Octane

How to monitor a Laravel application served by Octane

By default Inspector register a shutdown function to transfer data from your application to Inspector at the end of each request lifecycle.

Since Octane runs your application in a long-running process the shutdown functions will never be called until the Octane server is stopped.

You have to manually flush the data collected by Inspector at end of the HTTP request life cycle.

So instead of using the normal WebRequestMonitoring middelware you should attach to your routes the Octane specialized middleware.

Configure the Octane middleware

Register the InspectorOctaneMiddlewar in App\Http\Kernel instead of the WebRequestMonitoring class:

Laravel 11

use \Inspector\Laravel\Middleware\InspectorOctaneMiddleware;

return Application::configure(basePath: dirname(__DIR__))
        // routes
    ->withMiddleware(function (Middleware $middleware) {
        // Append the middleware
        $middleware->appendToGroup('web', InspectorOctaneMiddleware::class)
            ->appendToGroup('api', InspectorOctaneMiddleware::class);
    ->withExceptions(function (Exceptions $exceptions) {

Laravel <= 10

 * The application's route middleware groups.
 * @var array
protected $middlewareGroups = [
    'web' => [
    'api' => [

Now Inspector is able to recognize the end of a transaction and monitor your application properly.

No configuration is needed for artisan commands and background jobs. They will continue to be monitored as usual.

Last updated