Open juslintek opened 3 years ago
I've connected it with https://github.com/upscalesoftware/swoole-newrelic, but had to do it like that:
AttachNewRelicMiddleware
, code looks like this:
<?php
namespace App\LaravelS\EventsHandlers;
use Hhxsv5\LaravelS\Swoole\Events\ServerStartInterface; use Swoole\Http\Server; use Upscale\Swoole\Newrelic;
class AttachNewRelicMiddleware implements ServerStartInterface { /**
Create the event listener. */ public function __construct() { }
/**
@param Server $server */ public function handle(Server $server): void { $apm = new Newrelic\Apm(new Newrelic\Apm\TransactionFactory()); $apm->instrument($server);
unset($rum, $apm);
} }
2. Attach that EventHandler to `ServerStart` event in `config/laravels.conf`. Example (slice of laravels.conf):
```php
...
'event_handlers' => [
'ServerStart' => [\App\LaravelS\EventsHandlers\AttachNewRelicMiddleware::class],
],
...
newrelic_name_transaction
as soon as possible. The earliest point in laravel-s where it is possible with prepared \Illuminate\Http\Request $req
request. Is: laravels.received_request
event. So to solve that I attach anonymous event handler to this even using EventServiceProvider::boot
method, like this:
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider { /**
@var array */ protected $listen = [];
/**
And that's it. Compared to generic implementation its complicated. Guess it is very similar with Blackfire. :-) Everything else comes from general New Relic setup tutorial.
Hi, has anyone tried setting up a new relic or Blackfire? And how did it went, what step you needed to take? If for example worker serves more than single requests then start and exit worker events aren't too helpful. :)
What is the best approach for production profiling :-)