Create a gist now

Instantly share code, notes, and snippets.

@sahanh /newrelic.php
Last active Dec 14, 2015

What would you like to do?
A class to implement newrelic in laravel
<?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]);
}
}

danwall commented Jun 13, 2013

Nice script, I noticed that there's a typo on markBackgrondTask, it should be markBackgroundTask.

Owner

sahanh commented Aug 9, 2013

thanks @danwall fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment