Closed BigDaneLane closed 3 years ago
@miff2000 any chance you could fix this?
Yep, happy to! @BigDaneLane thanks for raising the issue 👍
I haven't set application name this way personally so I'm not sure what the best fix is. Setting the third parameter to true
seems to be an easy solution, and potentially the most correct one.
I was also thinking about the best way to fix it. For people like me who have New Relic config already set up setting the third parameter true
might be a performance impact like the docblock states. But there is no way to check if New Relic is already set up, and if this is the desired setting. Maybe add a variable to the config/newRelic.php file to check if the appName needs to be customised?
<?php
return [
~~~~
'custom_settings' => env('NEW_RELIC_CUSTOM_SETTINGS', false),
~~~~
And in the NewRelicMiddleware:
public function handle(Request $request, Closure $next)
{
// We must let the response get handled before naming the transaction, otherwise the necessary route i
// information won't be available in the request object.
$response = $next($request);
$this->newRelic->nameTransaction($this->getTransactionName($request));
if(config('newRelic.custom_settings')){
$this->newRelic->setAppName(
config('newRelic.application_name'),
config('newRelic.license'),
true
);
}
return $response;
}
Btw, thanks for the great work guys!
I would agree, it should be a setting that is overridden from defaults if there is a performance impact, and a blurb in the docs for it. This functionality was only just added so the impact will be minimal.
I can take care of that - you've done all the hard work for me anyway @BigDaneLane :)
What did you do?
Upgrade to 3.1.0
What did you expect to happen?
My transactions to show up in New Relic
What actually happened?
My transactions did not show up.
What versions of relevant language, framework and this module are you using?
nordsoftware/lumen-newrelic: "3.1.0" laravel/lumen-framework: "8.1" php: "7.3"
In NewRelicMiddleware.php on line 46 newRelic->setAppName is called:
Which calls this function:
The docblock states:
So when the NewRelicMiddleware is loaded (on the way out) the transaction up to that point is dropped. So the transactionName is not showing up in new relic.
When I change the $xmit parameter to 'true' the transaction does show up in New Relic. If I completely remove the '$this->newRelic->setAppName()'-function the transaction is also showing up.
On my server New Relic is already set up before creating the lumen app. So when calling the setAppName() it drops the transaction up to that point.
I've spend way too much time on this and hope by creating this issue it prevents other people from wasting time. I will stay on v3.0.0 which works for me