Skip to content

Instantly share code, notes, and snippets.

@sahanh
Last active December 14, 2015 07:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sahanh/5050326 to your computer and use it in GitHub Desktop.
Save sahanh/5050326 to your computer and use it in GitHub Desktop.
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
Copy link

danwall commented Jun 13, 2013

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

@sahanh
Copy link
Author

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