Exemplo n.º 1
0
 /**
  * @param \Nette\Application\Application $application
  * @param \Nette\Application\Request $request
  */
 public function __invoke(Application $application, Request $request)
 {
     if (PHP_SAPI === 'cli') {
         newrelic_background_job(TRUE);
     }
     $params = $request->getParameters();
     $action = $request->getPresenterName();
     if (isset($params[$this->actionKey])) {
         $action = sprintf('%s:%s', $action, $params[$this->actionKey]);
     }
     if (!empty($this->map)) {
         foreach ($this->map as $pattern => $appName) {
             if ($pattern === '*') {
                 continue;
             }
             if (Strings::endsWith($pattern, '*')) {
                 $pattern = Strings::substring($pattern, 0, -1);
             }
             if (Strings::startsWith($pattern, ':')) {
                 $pattern = Strings::substring($pattern, 1);
             }
             if (Strings::startsWith($action, $pattern)) {
                 \VrtakCZ\NewRelic\Tracy\Bootstrap::setup($appName, $this->license);
                 break;
             }
         }
     }
     newrelic_name_transaction($action);
     newrelic_disable_autorum();
 }
Exemplo n.º 2
0
 /**
  * Execute the action
  * We will build the classname, require the class and call the execute method.
  */
 protected function execute()
 {
     if (extension_loaded('newrelic')) {
         newrelic_background_job();
     }
     $this->loadConfig();
     // build action-class-name
     $actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Cronjobs\\' . $this->getAction();
     if ($this->getModule() == 'Core') {
         $actionClass = 'Backend\\Core\\Cronjobs\\' . $this->getAction();
     }
     // validate if class exists (aka has correct name)
     if (!class_exists($actionClass)) {
         // set correct headers
         \SpoonHTTP::setHeadersByCode(500);
         // throw exception
         throw new Exception('The cronjobfile is present, but the classname should be: ' . $actionClass . '.');
     }
     // create action-object
     $this->cronjob = new $actionClass($this->getKernel());
     $this->cronjob->setModule($this->getModule());
     $this->cronjob->setAction($this->getAction());
     if (extension_loaded('newrelic')) {
         newrelic_name_transaction('cronjob::' . $this->getModule() . '::' . $this->getAction());
     }
 }
Exemplo n.º 3
0
 /**
  * Build the named transaction based on an array of information from the route hook
  *
  * @param array $page_information the routing information
  *
  * @return void
  */
 protected static function buildTransaction($page_information)
 {
     if (empty($page_information) || !is_array($page_information)) {
         return;
     }
     $transaction = [];
     $identifier = elgg_extract('identifier', $page_information);
     if (!empty($identifier)) {
         $transaction[] = $identifier;
     }
     // filter out usernames
     $usernames = self::getUsernamesToIgnore();
     $segments = elgg_extract('segments', $page_information);
     if (!empty($segments) && is_array($segments)) {
         foreach ($segments as $segment) {
             if (is_numeric($segment) || in_array($segment, $usernames)) {
                 $transaction[] = '*';
                 break;
             } else {
                 $transaction[] = $segment;
             }
         }
     }
     newrelic_name_transaction('/' . implode('/', $transaction));
 }
 public static function route(Request $request)
 {
     $controller = $request->getController() . 'Controller';
     $method = $request->getMethod();
     $args = $request->getArgs();
     //$controllerFile = SITE_PATH.'controllers/'.$controller.'.php';  //***Because autoload
     //if(is_readable($controllerFile)){ //***Because autoload
     //require_once $controllerFile; //***Because autoload
     $controller = new $controller();
     $method = is_callable(array($controller, $method)) ? $method : 'index';
     if (!empty($args)) {
         //call_user_func_array(array($controller,$method),$args);
         if (extension_loaded('newrelic')) {
             newrelic_name_transaction((string) $request->getController() . '/' . (string) $method);
         }
         call_user_func(array($controller, $method), $args);
     } else {
         if (extension_loaded('newrelic')) {
             newrelic_name_transaction((string) $request->getController() . '/' . (string) $method);
         }
         call_user_func(array($controller, $method), NULL);
     }
     return;
     //} //***Because autoload
     throw new Exception('404 - ' . $request->getController() . ' not found');
 }
Exemplo n.º 5
0
 /**
  * @param $name
  */
 public function setNameTransaction($name)
 {
     $this->debug('Calling setNameTransaction', array($name));
     if ($this->functionExists('newrelic_name_transaction')) {
         newrelic_name_transaction($name);
     }
 }
Exemplo n.º 6
0
 /**
  * Hook to record all fron controller events
  * @param Varien_Event_Observer $observer 
  */
 public function controller_action_predispatch(Varien_Event_Observer $observer)
 {
     try {
         if (extension_loaded('newrelic')) {
             $controllerAction = $observer->getControllerAction();
             $request = $controllerAction->getRequest();
             $controllerName = explode("_", $request->getControllerName());
             if (Mage::getStoreConfig('newrelic/settings/ignore_admin_routes') && $request->getRouteName() == 'adminhtml' || $request->getModuleName() == 'admin' || in_array('adminhtml', $controllerName)) {
                 Mage::Helper('newrelic')->setAppName(false);
                 newrelic_ignore_transaction();
                 newrelic_ignore_apdex();
                 return $this;
             }
             if (mage::helper('newrelic')->ignoreModule($request->getModuleName()) === true) {
                 Mage::Helper('newrelic')->setAppName(false);
                 newrelic_ignore_transaction();
                 newrelic_ignore_apdex();
                 return $this;
             }
             if (Mage::getStoreConfig('newrelic/settings/named_transactions')) {
                 $route = $request->getRouteName() . '/' . $request->getControllerName() . '/' . $request->getActionName();
                 if (Mage::getStoreConfig('newrelic/settings/add_module_to_named_transactions')) {
                     $route .= ' (module: ' . $request->getModuleName() . ')';
                 }
                 newrelic_name_transaction($route);
                 Mage::Helper('newrelic')->setAppName(true);
                 return $this;
             }
         }
     } catch (Exception $e) {
         mage::logException($e);
     }
 }
Exemplo n.º 7
0
 /**
  * Execute the action
  * We will build the classname, require the class and call the execute method.
  */
 protected function execute()
 {
     if (extension_loaded('newrelic')) {
         newrelic_background_job();
     }
     $this->loadConfig();
     // build action-class-name
     $actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Cronjobs\\' . $this->getAction();
     if ($this->getModule() == 'Core') {
         $actionClass = 'Backend\\Core\\Cronjobs\\' . $this->getAction();
     }
     // validate if class exists (aka has correct name)
     if (!class_exists($actionClass)) {
         // set correct headers
         header('HTTP/1.1 500 Internal Server Error');
         // throw exception
         throw new Exception('The cronjobfile ' . $actionClass . ' could not be found.');
     }
     // create action-object
     $this->cronjob = new $actionClass($this->getKernel());
     $this->cronjob->setModule($this->getModule());
     $this->cronjob->setAction($this->getAction());
     if (extension_loaded('newrelic')) {
         newrelic_name_transaction('cronjob::' . $this->getModule() . '::' . $this->getAction());
     }
 }
Exemplo n.º 8
0
 /**
  * @param string $name
  */
 public function setNameTransaction($name)
 {
     $name = (string) $name;
     if ($this->getEnabled()) {
         newrelic_name_transaction($name);
     }
 }
 /**
  * beforeDispatch() method.
  *
  * Call the newrelic_name_transaction function when the newrelic extension
  * is loaded.
  *
  * @param Cake\Event\Event $event The event.
  * @return void
  */
 public function beforeDispatch(Event $event)
 {
     if (extension_loaded('newrelic')) {
         $request = $event->data['request'];
         newrelic_name_transaction($this->nameTransaction($request));
     }
 }
Exemplo n.º 10
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (extension_loaded('newrelic')) {
         newrelic_name_transaction(sprintf('%s (%s)', $request->getRequestUri(), $request->method()));
     }
     return $next($request);
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function nameTransaction($name)
 {
     if (!$this->extensionLoaded()) {
         return $this;
     }
     newrelic_name_transaction($name);
     return $this;
 }
Exemplo n.º 12
0
 /**
  * Start a New Relic transaction
  *
  * @param  string $name
  * @return void
  */
 public function start($name = null)
 {
     if (!$this->hasNewRelic()) {
         return;
     }
     newrelic_start_transaction(NEW_RELIC_APP_NAME);
     if ($name) {
         $this->currentTransactionName = $name;
     }
     newrelic_name_transaction($this->currentTransactionName);
 }
 /**
  * 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;
 }
Exemplo n.º 14
0
 public function on_start()
 {
     if (extension_loaded('newrelic')) {
         $site = Config::get('newrelic.site') ? Config::get('newrelic.site') : 'concrete5';
         newrelic_set_appname($site);
         Events::addListener('on_page_view', function ($event) {
             $c = $event->getPageObject();
             $path = $c->getCollectionPath() ? $c->getCollectionPath() : '/';
             newrelic_name_transaction($path);
         });
     }
 }
Exemplo n.º 15
0
 /**
  * Give New Relic a name for this transaction
  *
  * @access	public
  * @return	void
  */
 public function name_transaction()
 {
     $transaction_name = (string) ee()->uri->segment(1);
     if (ee()->uri->segment(2) !== FALSE) {
         $transaction_name .= '/' . ee()->uri->segment(2);
     }
     // Append site label if MSM is enabled to easily differentiate
     // between similar requests
     if (ee()->config->item('multiple_sites_enabled') == 'y') {
         $transaction_name .= ' - ' . ee()->config->item('site_label');
     }
     newrelic_name_transaction($transaction_name);
 }
 public function onRequest(Application $app, Request $request)
 {
     if (!extension_loaded('newrelic')) {
         return;
     }
     if (PHP_SAPI === 'cli') {
         newrelic_name_transaction('$ ' . basename($_SERVER['argv'][0]) . ' ' . implode(' ', array_slice($_SERVER['argv'], 1)));
         newrelic_background_job(TRUE);
         return;
     }
     $params = $request->getParameters();
     newrelic_name_transaction($request->getPresenterName() . (isset($params['action']) ? ':' . $params['action'] : ''));
 }
Exemplo n.º 17
0
 /**
  * Executed after action
  * @author Adegoke Obasa <*****@*****.**>
  * @param \yii\base\Action $action
  * @param mixed $result
  * @return mixed
  */
 public function afterAction($action, $result)
 {
     $result = parent::afterAction($action, $result);
     $this->setSecurityHeaders();
     /**
      * Set Current Transaction in New Relic
      * @author Adegoke Obasa <*****@*****.**>
      */
     if (extension_loaded('newrelic')) {
         newrelic_name_transaction($action->controller->id . '/' . $action->id);
     }
     return $result;
 }
 function __destruct()
 {
     if ($this->transactionName) {
         //Debug::message("newrelic_name_transaction($this->transactionName)");
         if (extension_loaded('newrelic')) {
             newrelic_name_transaction($this->transactionName);
         }
         if ($memberID = Session::get('loggedInAs')) {
             //Debug::message("newrelic_add_custom_parameter('memberID', $memberID)");
             if (extension_loaded('newrelic')) {
                 newrelic_add_custom_parameter('memberID', $memberID);
             }
         }
     }
 }
 public function onRequest(Application $app, Request $request)
 {
     if (!extension_loaded('newrelic')) {
         return;
     }
     if (PHP_SAPI === 'cli') {
         // uložit v čitelném formátu
         newrelic_name_transaction('$ ' . basename($_SERVER['argv'][0]) . ' ' . implode(' ', array_slice($_SERVER['argv'], 1)));
         // označit jako proces na pozadí
         newrelic_background_job(TRUE);
         return;
     }
     // pojmenování požadavku podle presenteru a akce
     $params = $request->getParameters();
     newrelic_name_transaction($_SERVER['HTTP_HOST'] . " | " . $request->getPresenterName() . (isset($params['action']) ? ':' . $params['action'] : ''));
 }
Exemplo n.º 20
0
 /**
  * Makes a more useful name for the transaction
  */
 public function nameTransaction()
 {
     // Add the first and second segements
     $name = craft()->request->getSegment(1);
     if (craft()->request->getSegment(2)) {
         $name .= "/" . craft()->request->getSegment(2);
     }
     // If it was a live preview request then prepend a label for that
     if (craft()->request->isLivePreview()) {
         $name = "/LivePreview/{$name}";
     } elseif (craft()->request->isCpRequest()) {
         $name = craft()->config->get('cpTrigger') . "/{$name}";
     }
     // Add the transaction through the PHP agenet API
     newrelic_name_transaction($name);
 }
Exemplo n.º 21
0
/**
 * bootstrap - ProcessMaker Bootstrap
 * this file is used initialize main variables, redirect and dispatch all requests
 */

function transactionLog($transactionName){
    if (extension_loaded('newrelic')) {
        $baseName="ProcessMaker";

        //Application base name
        newrelic_set_appname ($baseName);


        //Custom parameters
        if(defined("SYS_SYS")){
            newrelic_add_custom_parameter ("workspace", SYS_SYS);
        }
        if(defined("SYS_LANG")){
            newrelic_add_custom_parameter ("lang", SYS_LANG);
        }
        if(defined("SYS_SKIN")){
            newrelic_add_custom_parameter ("skin", SYS_SKIN);
        }
        if(defined("SYS_COLLECTION")){
            newrelic_add_custom_parameter ("collection", SYS_COLLECTION);
        }
        if(defined("SYS_TARGET")){
            newrelic_add_custom_parameter ("target", SYS_TARGET);
        }
        if(defined("SYS_URI")){
            newrelic_add_custom_parameter ("uri", SYS_URI);
        }
        if(defined("PATH_CORE")){
            newrelic_add_custom_parameter ("path_core", PATH_CORE);
        }
        if(defined("PATH_DATA_SITE")){
            newrelic_add_custom_parameter ("path_site", PATH_DATA_SITE);
        }

        //Show correct transaction name
        if(defined("SYS_SYS")){
            newrelic_set_appname ("PM-".SYS_SYS.";$baseName");
        }
        if(defined("PATH_CORE")){
            $transactionName=str_replace(PATH_CORE,"",$transactionName);
        }
        newrelic_name_transaction ($transactionName);
    }
}
Exemplo n.º 22
0
 protected function preDispatch()
 {
     $is_ajax = $this->isAjax();
     $this->view->is_ajax = $is_ajax;
     if ($is_ajax) {
         $this->view->cleanTemplateAfter();
         $this->view->setLayout(null);
     }
     if ($this->hasParam('debug') && $this->getParam('debug') === 'true' && FA_APPLICATION_ENV != 'production') {
         error_reporting(E_ALL & ~E_STRICT);
         ini_set('display_errors', 1);
     }
     // NewRelic Logging.
     if (function_exists('newrelic_name_transaction')) {
         $app_url = '/' . $this->dispatcher->getModuleName() . '/' . $this->dispatcher->getControllerName() . '/' . $this->dispatcher->getActionName();
         newrelic_name_transaction($app_url);
     }
     return true;
 }
Exemplo n.º 23
0
 /**
  * This method exists because the service container needs to be set before
  * the request's functionality gets loaded.
  */
 public function initialize()
 {
     $request = $this->getContainer()->get('request');
     // get vars
     if ($request->request->has('fork')) {
         $post = $request->request->get('fork');
         $module = isset($post['module']) ? $post['module'] : '';
         $action = isset($post['action']) ? $post['action'] : '';
         $language = isset($post['language']) ? $post['language'] : '';
     } else {
         $module = $request->query->get('module');
         $action = $request->query->get('action');
         $language = $request->query->get('language');
     }
     if ($language == '') {
         $language = SITE_DEFAULT_LANGUAGE;
     }
     try {
         $this->setModule($module);
         $this->setAction($action);
         $this->setLanguage($language);
         if (extension_loaded('newrelic')) {
             newrelic_name_transaction('ajax::' . $module . '::' . $action);
         }
         $this->ajaxAction = new AjaxAction($this->getKernel(), $this->getAction(), $this->getModule());
         $this->output = $this->ajaxAction->execute();
     } catch (InvalidArgumentException $e) {
         $message = Model::getContainer()->getParameter('fork.debug_message');
         $this->ajaxAction = new FrontendBaseAJAXAction($this->getKernel(), '', '');
         $this->ajaxAction->output(FrontendBaseAJAXAction::ERROR, null, $message);
         $this->output = $this->ajaxAction->execute();
     } catch (Exception $e) {
         if (Model::getContainer()->getParameter('kernel.debug')) {
             $message = $e->getMessage();
         } else {
             $message = Model::getContainer()->getParameter('fork.debug_message');
         }
         $this->ajaxAction = new FrontendBaseAJAXAction($this->getKernel(), '', '');
         $this->ajaxAction->output(FrontendBaseAJAXAction::ERROR, null, $message);
         $this->output = $this->ajaxAction->execute();
     }
 }
Exemplo n.º 24
0
 /**
  * {@inheritdoc}
  */
 public function process(Message $message, array $options)
 {
     if ($this->extensionLoaded) {
         newrelic_start_transaction($options['new_relic_app_name'], $options['new_relic_license']);
         newrelic_name_transaction($options['new_relic_transaction_name']);
         newrelic_background_job(true);
     }
     try {
         $result = $this->processor->process($message, $options);
     } catch (\Exception $e) {
         if ($this->extensionLoaded) {
             newrelic_notice_error(null, $e);
             newrelic_end_transaction();
         }
         throw $e;
     }
     if ($this->extensionLoaded) {
         newrelic_end_transaction();
     }
     return $result;
 }
Exemplo n.º 25
0
 /**
  * Method to initialize the profiler
  *
  * @access public
  * @param null
  * @return null
  */
 public static function init()
 {
     // Do not continue when the PHP-extension "newrelic" is not found
     if (!extension_loaded('newrelic')) {
         return;
     }
     // Do not continue when the proper functions are not loaded
     if (!function_exists('newrelic_add_custom_tracer')) {
         return;
     }
     // Add generic NewRelic calls that don't have dependancies on Magento
     static $initialized = false;
     if ($initialized == false) {
         newrelic_add_custom_tracer('Mage::getModel');
         newrelic_add_custom_tracer('Mage::getSingleton');
         newrelic_add_custom_tracer('Mage::helper');
         newrelic_add_custom_tracer('Mage::log');
         newrelic_add_custom_tracer('Mage_Core_Model_App::_initCache');
         newrelic_add_custom_tracer('Mage_Core_Model_Config::loadDb');
         newrelic_add_custom_tracer('Mage_Core_Model_Config::loadModules');
         newrelic_add_custom_tracer('include');
         newrelic_add_custom_tracer('include_once');
         newrelic_add_custom_tracer('require');
         newrelic_add_custom_tracer('require_once');
         $initialized = true;
     }
     // Register the Magento request (once it is loaded in Magento) with NewRelic
     static $request_logged = false;
     if ($request_logged == false) {
         $request = Mage::app()->getRequest();
         if (!empty($request)) {
             $request_logged = true;
             if (function_exists('newrelic_name_transaction')) {
                 newrelic_name_transaction($request->getRequestUri());
             }
         }
     }
 }
Exemplo n.º 26
0
 public function handleRequest(RequestInterface $request, ResponseInterface $response)
 {
     $this->preFilters->processFilters($request, $response);
     $command = $this->resolver->getCommand($request, $response);
     /*
      * test about ?cmd=xxx to choose the right controller
      * if cmd not found, we use cmd=main as default
      */
     if ($request->issetParameter('action') === false) {
         $cmd = 'main';
     } else {
         $cmd = $request->getParameter('action');
     }
     if (method_exists($command, $cmd) === false) {
         throw new \Exception('There is no method "' . $cmd . '"', 404);
     }
     if (extension_loaded('newrelic')) {
         newrelic_name_transaction(join('', array_slice(explode('\\', get_class($command)), -1)) . '/' . $cmd);
     }
     $command->{$cmd}();
     $this->postFilters->processFilters($request, $response);
     $response->flush();
 }
Exemplo n.º 27
0
$request = Request::createFromGlobals();
if (!file_exists($parametersFile)) {
    $env = 'install';
    if (strpos($request->getRequestUri(), '/install') !== 0) {
        // check .htaccess
        if (!$request->query->has('skiphtaccess') && !file_exists('.htaccess')) {
            echo 'Your install is missing the .htaccess file. Make sure you show
                 hidden files while uploading Fork CMS. Read the article about
                 <a href="http://www.fork-cms.com/community/documentation/detail/installation/webservers">webservers</a>
                 for further information. <a href="?skiphtaccess">Skip .htaccess
                 check</a>';
            return;
        }
        header('Location: /install');
        return;
    }
}
require_once __DIR__ . '/app/AppKernel.php';
if (extension_loaded('newrelic')) {
    newrelic_name_transaction(strtok($request->getRequestUri(), '?'));
}
if ($debug) {
    Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$response = $kernel->handle($request);
if ($response->getCharset() === null && $kernel->getContainer() instanceof ContainerInterface) {
    $response->setCharset($kernel->getContainer()->getParameter('kernel.charset'));
}
$response->send();
$kernel->terminate($request, $response);
Exemplo n.º 28
0
 /**
  * @param $name
  */
 protected function setNewrelicTransactionName()
 {
     if (!extension_loaded('newrelic')) {
         return;
     }
     $name = NULL;
     if (isset($this->transactionNameDefault)) {
         $name = $this->transactionNameDefault;
     }
     if (isset($this->transactionName)) {
         $name = $this->transactionName;
     }
     if (isset($this->transactionNameOverride)) {
         $name = $this->transactionNameOverride;
     }
     if (!is_null($name)) {
         $name .= $this->transactionNamePostfix;
         newrelic_name_transaction($name);
     }
 }
Exemplo n.º 29
0
 public function setTransactionName($name)
 {
     newrelic_name_transaction($name);
 }
Exemplo n.º 30
0
$app->register(new Silex\Provider\DoctrineServiceProvider(), ['db.options' => include sprintf('%s/src/Config/credentials.%s.php', BASE_DIR, APP_NAME)]);
$app['guzzle'] = $app->share(function () use($app) {
    return new Guzzle\Http\Client();
});
$app->register(new Silex\Provider\ServiceControllerServiceProvider());
$app->register(new Silex\Provider\ValidatorServiceProvider());
$app['home'] = $app->share(function () use($app) {
    return new Controllers\Home();
});
$app['versions'] = $app->share(function () use($app) {
    $versions = new Models\Versions($app['db']);
    return new Controllers\Versions($versions);
});
$app->before(function (Request $request, Silex\Application $app) {
    if (extension_loaded('newrelic')) {
        newrelic_name_transaction(current(explode('?', $_SERVER['REQUEST_URI'])));
    }
});
$app->after(function (Request $request, Response $response) {
    $response->headers->set('Access-Control-Allow-Origin', '*');
    $response->headers->set('Access-Control-Allow-Methods', 'GET,POST,HEAD,DELETE,PUT,OPTIONS');
    $response->headers->set('Access-Control-Allow-Headers', 'Content-Type');
    if ($response->getStatusCode() == 200) {
        $response->headers->set('Content-Type', 'application/json; charset=UTF-8');
    }
});
$app->match("{url}", function ($url) use($app) {
    return "OK";
})->assert('url', '.*')->method("OPTIONS");
$app->get('/projects/{project}/latest', 'versions:latest');
$app->get('/', 'home:index');