Skip to content

Instantly share code, notes, and snippets.

@m3m0r7
Created October 27, 2020 10:47
Show Gist options
  • Save m3m0r7/9f308c67756ff398359dfba07151599f to your computer and use it in GitHub Desktop.
Save m3m0r7/9f308c67756ff398359dfba07151599f to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class Newrelic
{
public function handle(Request $request, \Closure $next)
{
if (!extension_loaded('newrelic')) {
return $next($request);
}
newrelic_start_transaction(
ini_get('newrelic.appname'),
ini_get('newrelic.license')
);
newrelic_background_job(false);
return $next($request);
}
public function terminate(Request $request, Response $response)
{
if (!extension_loaded('newrelic')) {
return;
}
newrelic_end_transaction();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment