Last active
December 14, 2015 07:28
-
-
Save sahanh/5050326 to your computer and use it in GitHub Desktop.
A class to implement newrelic in laravel
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 | |
class NewRelic | |
{ | |
public static function __callStatic($method, $params) | |
{ | |
if (!extension_loaded('newrelic')) { | |
return null; | |
} | |
//new named transaction | |
if ($method == 'captureTransaction') { | |
return newrelic_name_transaction(array_get($params, 0)); | |
} | |
if ($method == 'captureException') { | |
return newrelic_notice_error('', array_get($params, 0)); | |
} | |
if ($method == 'browserHeader') { | |
return newrelic_get_browser_timing_header(); | |
} | |
if ($method == 'browserFooter') { | |
return newrelic_get_browser_timing_footer(); | |
} | |
if ($method == 'setCustomParameter') { | |
return newrelic_add_custom_parameter(array_get($params, 0), array_get($params, 1)); | |
} | |
if ($method == 'markBackgroundTask') { | |
return newrelic_background_job(true); | |
} | |
throw new Exception('Method not found.'); | |
} | |
public function __call($method, $params) | |
{ | |
return call_user_func_array("static::__callStatic", [$method, $params]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice script, I noticed that there's a typo on markBackgrondTask, it should be markBackgroundTask.