/**
  * Invoke
  *
  * @return void
  */
 public function __invoke(Request $request, Response $response, callable $next)
 {
     if (!extension_loaded('newrelic')) {
         $response = $next($request, $response);
         return $response;
     }
     newrelic_name_transaction($request->getRoute()->getPattern());
     newrelic_capture_params(true);
     $response = $next($request, $response);
     return $response;
 }
 public function __construct($go_newrelic)
 {
     // get the calling object
     $this->go_newrelic = $go_newrelic;
     // can't lazy load the config, we need
     $this->config = $this->go_newrelic->config();
     // the license key is typically set elsewhere during the daemon/module installation,
     // but this allows some potential future where the license key is set in the WP dashboard
     if (!empty($this->config['license'])) {
         ini_set('newrelic.license', $this->config['license']);
     }
     // END if
     // set the app name
     newrelic_set_appname($this->go_newrelic->get_appname());
     // basic settings
     // make sure the config isn't empty or invalid for any of these
     // ...sanity and validation intentionally skipped for performance reasons
     ini_set('newrelic.framework', 'wordpress');
     ini_set('newrelic.transaction_tracer.detail', $this->config['transaction-tracer-detail']);
     ini_set('newrelic.error_collector.enabled', $this->config['error-collector-enabled']);
     if (isset($this->config['capture-params']) && $this->config['capture-params']) {
         newrelic_capture_params();
     }
     // END if
     ini_set('newrelic.ignored_params', $this->go_newrelic->config('ignored-params'));
     // set logging parameters based on request context
     // ajax responses _cannot_ have RUM in them, for example
     if (is_admin()) {
         if (defined('DOING_AJAX') && DOING_AJAX) {
             newrelic_disable_autorum();
         }
         // END if
     } elseif (defined('DOING_CRON') && DOING_CRON) {
         newrelic_disable_autorum();
     } else {
         // add more tracking of the template pieces
         add_action('template_include', array($this, 'template_include'));
     }
     // END else
     // track the user info
     add_action('init', array($this, 'init'));
 }
예제 #3
0
 /**
  * Listen to the event controller_action_predispatch
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function controllerActionPredispatch(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->_isEnabled()) {
         return $this;
     }
     $this->_setupAppName();
     $this->_trackControllerAction($observer->getEvent()->getControllerAction());
     // Ignore Apdex for Magento Admin Panel pages
     if ($this->helper->isAdmin()) {
         if (function_exists('newrelic_ignore_apdex')) {
             newrelic_ignore_apdex();
         }
     }
     // Common settings
     if (function_exists('newrelic_capture_params')) {
         newrelic_capture_params(true);
     }
     return $this;
 }
예제 #4
0
 /**
  * Enable/disable the capturing of URL parameters for displaying in
  * transaction traces.
  *
  * @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-capture-params
  *
  * @param bool $enable
  */
 public function captureParams($enable = true)
 {
     if ($this->isLoaded()) {
         newrelic_capture_params($enable);
     }
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function captureParams($enabled = true)
 {
     if ($this->extensionLoaded()) {
         newrelic_capture_params((bool) $enabled);
     }
 }
예제 #6
0
        }
        $_SERVER['USER_ADDR'] = $_SERVER[$key];
        break;
    }
}
// Prevents the New Relic output filter from attempting to insert RUM JavaScript.
if (extension_loaded('newrelic')) {
    newrelic_disable_autorum();
    // add any calls to newrelic_add_custom_tracer() here
    if (is_array($_SERVER) && isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
        // Web requests
        if (!preg_match(';^(.*\\.|)[^.]+\\.[^.]{2,}$;i', $_SERVER['HTTP_HOST'])) {
            newrelic_ignore_transaction();
        } else {
            newrelic_set_appname($_SERVER['HTTP_HOST']);
            newrelic_capture_params();
            $baseURI = preg_replace(';[?&#].*;', '', $_SERVER['REQUEST_URI']);
            if ($baseURI != '/' && $baseURI != '') {
                newrelic_name_transaction($baseURI);
            }
        }
    } else {
        // Command line scripts
        newrelic_background_job(true);
    }
}
if (defined('ROLLBAR_ACCESS_TOKEN') && defined('DEPLOY_ROOT')) {
    @(include_once 'scripts/rollbar/rollbar.php');
    if (class_exists('Rollbar')) {
        $config = array('access_token' => constant('ROLLBAR_ACCESS_TOKEN'));
        if (defined('ROLLBAR_HANDLER')) {
예제 #7
0
 /**
  * If enabled, this enabled the capturing of URL parameters for displaying
  * in transaciton traces.  This overrides the newrelic.capture_params
  * setting.
  *
  * @param boolean $enable true if enabled, false if not.
  */
 public function captureParams($enable = false)
 {
     if ($this->skip()) {
         return;
     }
     if ($enable) {
         newrelic_capture_params('on');
     } else {
         newrelic_capture_params(false);
     }
 }
예제 #8
0
 /**
  * Should NewRelic capture params ?
  *
  * @param  boolean $boolean
  * @return void
  */
 public function captureParams($boolean)
 {
     if (!$this->hasNewRelic()) {
         return;
     }
     newrelic_capture_params($boolean);
 }
예제 #9
0
 /**
  * Enable capture request params, only for web application
  * @return boolean|null true on success
  */
 public function catchRequestParams()
 {
     if (Yii::$app instanceof WebApplication) {
         return newrelic_capture_params(true);
     }
 }