Created
October 27, 2020 10:47
-
-
Save m3m0r7/9f308c67756ff398359dfba07151599f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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