roadrunner-server / roadrunner-plugins

📦 Home for the roadrunner plugins
MIT License
25 stars 9 forks source link

[FEATURE REQUEST] New Relic Support #85

Closed ahoulgrave closed 2 years ago

ahoulgrave commented 4 years ago

First of all, thanks for your software. It's been a great experience working with it.

I moved my Symfony application to Roadrunner, which improved the performance, but New Relic integration does not seem to work.

I was wondering if anyone has successfully integrated it, or you have any tips on this.

Thanks in advance.

iluuu1994 commented 3 years ago

Parts of it can be solved with this but New Relic will still be missing a lot of information (like request url, headers, params, etc). It doesn't look like you can set these manually in the extension at the time.

wolfy-j commented 3 years ago

It might make more sense to add new relic as rr plugin rather than tackle PHP code.

iluuu1994 commented 3 years ago

Possibly. Although allowing to configure a custom request would also solve the problem for other services with a similar architecture as RoadRunner (like PHP-PM).

iluuu1994 commented 3 years ago

See this comment. A simple solution would be to offer something like PHP-PM does with populate-server-var that populates the $_SERVER variable which would allow New Relic to look up the given request details. This can be implemented in user land but it might still be convenient for RoadRunner to offer such an option.

rustatian commented 2 years ago

We will provide the New Relic middleware, so, you'll be able to see the traces and attach information from the payload to them. Actually, the main challenge here is to extend transactions from the Golang part with the actions which act inside the PHP worker. I don't know much about PHP and PHP New Relic implementation, but, if PHP NR is able to consume and expand transactions from the outside, please, let me know and I'll provide the necessary information to the PHP worker.

arku31 commented 2 years ago

We agreed to develop a solution that will take data from Response headers. We agreed to use the following structure.

$rrNewrelic= [
    'shopId:1', //custom data
    'auth:password', //custom data
    'transaction_name:transcationName', //name - special key to override the name. By default it will use requestUri. 
];

$rrNewrelicHeaders = ['nr_segment1', 'nr_segments2'];

$nr_segment1 = [ //for segments tracking. Optional
            'name:redis',
            'time:10222', //ms divided on 1000
            'key:debug_key_that_we_have_in_redis'
            'key2:another_key'
];

$nr_segment2 = [ //for segments tracking. Optional
            'name:elasticsearch',
            'time:10222', //ms divided on 1000
            'index:test_1'
];

This can be passed as

$response = $response->withHeader('rr_newrelic', $rrNewRelic);
$response = $response->withHeader('rr_newrelic_headers', $rrNewRelicHeaders);
$response = $response->withHeader('nr_segment1', $nr_segment1);
$response = $response->withHeader('nr_segment2', $nr_segment2);

For now, we are going to implement only the first part. The second part is not possible at this moment as there is no way to set the duration for the segment using the original newrelic library - additional investigation is required.