Open fizerkhan opened 8 months ago
@fizerkhan Could you please clarify how you intend to use this library with Laravel Octane? It would really help if you could provide some code samples of what you're trying to do.
@fizerkhan
The error means that the request handling middleware hasn't been registered. Make sure to use the library after $server->on('Request', ...)
call (implemented somewhere in Laravel Octane framework).
@sshymko Thanks for the response.
I am trying to use this Swoole integration - https://github.com/upscalesoftware/swoole-newrelic with my Laravel Octane app (based on Swoole).
I could not find the $server->on('Request', ...)
call.
I don't know where to include the below steps in the Laravel Octane app
$apm = new Newrelic\Apm(new Newrelic\Apm\TransactionFactory());
$apm->instrument($server);
@fizerkhan
Researched a little bit how Laravel Octane framework is organized. Script bin/swoole-server bootstraps a Swoole server. New Relic instrumentation need to take place after $server->on('request', ...)
but before $server->start()
.
Unfortunately, Laravel Octane doesn't seem to provide a way to customize its Swoole bootstrap before the server starts. You'd have to resort to a more elaborate process involving copying and modifying files.
The workaround:
vendor/laravel/octane/bin/swoole-server
to a new file my-swoole-server
in the project rootmy-swoole-server
script to replace __DIR__
with 'vendor/laravel/octane/bin'
Add New Relic instrumentation to my-swoole-server
script before $server->start()
:
...
$apm = new Newrelic\Apm(new Newrelic\Apm\TransactionFactory());
$apm->instrument($server);
unset($apm);
$server->start();
./my-swoole-server
instead of:
./vendor/bin/swoole-server
I am getting this error in
Laravel Octane.
Any idea how to fix it?