Example #1
0
 /**
  * Add a custom parameter to the current web transaction with the specified
  * value.
  *
  * @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-custom-param
  *
  * @param string $key
  * @param mixed  $value
  *
  * @return bool
  */
 public function addCustomParameter($key, $value)
 {
     if (!$this->isLoaded()) {
         return false;
     }
     return newrelic_add_custom_parameter($key, $value);
 }
 public function __construct($message = "", $code = 0, \Exception $previous = null)
 {
     parent::__construct($message, $code, $previous);
     if (extension_loaded("newrelic")) {
         newrelic_add_custom_parameter("errorDetails: " . $this->getMessage());
     }
 }
 /**
  * Wrapper for 'newrelic_add_custom_parameter' function
  * 
  * @param string $param
  * @param string|int $value
  * @return bool
  */
 public function addCustomParameter($param, $value)
 {
     if (extension_loaded('newrelic')) {
         newrelic_add_custom_parameter($param, $value);
         return true;
     }
     return false;
 }
 /**
  * Record an attribute as Newrelic's custom parameter
  *
  * @param string $key Attribute key
  * @param mixed $value Attribute value
  */
 public function onAttributeChange($key, $value)
 {
     if (function_exists('newrelic_add_custom_parameter')) {
         if (is_bool($value)) {
             $value = $value ? "yes" : "no";
         }
         newrelic_add_custom_parameter($key, $value);
     }
 }
 /**
  * Set the transaction name to be the controller plus either init-only or index depending on what happened, if this is a page controller set the page link
  */
 public function onAfterInit()
 {
     $controller = get_class($this->owner);
     if ($this->owner->getResponse()->isFinished()) {
         newrelic_name_transaction("{$controller}/init-only");
     } else {
         newrelic_name_transaction("{$controller}/index");
     }
     //Append the page link
     if ($this->owner instanceof Page_Controller) {
         newrelic_add_custom_parameter('ssPageLink', $this->owner->Link());
     }
     //Append the host name for the server
     newrelic_add_custom_parameter('server_name', @gethostname());
 }
 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);
             }
         }
     }
 }
Example #7
0
 /**
  * @param array $record
  * @throws Exception\RuntimeException
  */
 public function write(array $record)
 {
     if (!$this->isEnabled()) {
         throw new Exception\RuntimeException('The newrelic PHP extension is required to use the NewRelicHandler');
     }
     if ($name = $this->getName($record['context'])) {
         $this->setName($name);
     }
     if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
         newrelic_notice_error($record['message'], $record['context']['exception']);
         unset($record['context']['exception']);
     } else {
         newrelic_notice_error($record['message']);
     }
     foreach ($record['context'] as $key => $parameter) {
         newrelic_add_custom_parameter($key, $parameter);
     }
 }
Example #8
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);
    }
}
Example #9
0
 /**
  * {@inheritDoc}
  */
 protected function write(array $record)
 {
     if (!$this->isNewRelicEnabled()) {
         throw new ehough_epilog_handler_MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler');
     }
     if ($appName = $this->getAppName($record['context'])) {
         $this->setNewRelicAppName($appName);
     }
     if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
         newrelic_notice_error($record['message'], $record['context']['exception']);
         unset($record['context']['exception']);
     } else {
         newrelic_notice_error($record['message']);
     }
     foreach ($record['context'] as $key => $parameter) {
         newrelic_add_custom_parameter($key, $parameter);
     }
     foreach ($record['extra'] as $key => $parameter) {
         newrelic_add_custom_parameter($key, $parameter);
     }
 }
Example #10
0
 public function runSync()
 {
     $helper = Mage::helper('unityreports');
     if (!$helper->isActive()) {
         $helper->debug('Sync is deactivated');
         return false;
     }
     try {
         $client = $this->_getClient();
         //add some tracing
         if (function_exists('newrelic_add_custom_parameter')) {
             newrelic_add_custom_parameter(sync_type, self::ENTITY_TYPE);
             newrelic_add_custom_parameter(sync_max, Intelivemetrics_Unityreports_Model_Utils::getMaxItemsPerSync());
         }
         // get data
         $abcarts = $this->_getData(Intelivemetrics_Unityreports_Model_Utils::getMaxItemsPerSync());
         if (is_null($abcarts)) {
             return self::NOTHING_TO_SYNC;
         }
         //get token
         $response = json_decode($client->getToken($helper->getApiKey(), $helper->getApiSecret(), $helper->getLicenseKey()));
         if ($response->code != 'OK') {
             $helper->debug('Cannot get a valid Token.' . $response->msg);
             return false;
         }
         //see bellow, we don't mark them at this stage, but earlier
         $this->markSentItems($abcarts);
         //send data
         $blob = Intelivemetrics_Unityreports_Model_Utils::prepareDataForSending($abcarts);
         $client->post($response->msg, array('type' => 'SYNC', 'data' => $blob, 'license' => $helper->getLicenseKey(), 'entity' => self::ENTITY_TYPE));
         $helper->debug('Sending ' . count($abcarts) . ' ' . self::ENTITY_TYPE);
         return true;
     } catch (Exception $e) {
         $helper->debug($e, Zend_Log::ERR);
         $helper->debug('FILE: ' . __FILE__ . 'LINE: ' . __LINE__);
         return false;
     }
 }
Example #11
0
 public function runSync()
 {
     $helper = Mage::helper('unityreports');
     if (!$helper->isActive()) {
         $helper->debug('Sync is deactivated');
         return false;
     }
     try {
         $client = $this->_getClient();
         //add some tracing
         if (function_exists('newrelic_add_custom_parameter')) {
             newrelic_add_custom_parameter('sync_type', $this->_getEntityType());
             newrelic_add_custom_parameter('sync_max', Intelivemetrics_Unityreports_Model_Utils::getMaxItemsPerSync());
         }
         //get data
         $data = $this->_getData(Intelivemetrics_Unityreports_Model_Utils::getMaxItemsPerSync());
         if (is_null($data)) {
             return self::NOTHING_TO_SYNC;
         }
         //get token
         $response = json_decode($client->getToken($helper->getApiKey(), $helper->getApiSecret(), $helper->getLicenseKey()));
         if ($response->code != 'OK') {
             $helper->debug('Cannot get a valid Token.' . $response->msg);
             return false;
         }
         $token = $response->msg;
         //send data
         $blob = Intelivemetrics_Unityreports_Model_Utils::prepareDataForSending($data);
         $response = json_decode($client->post($token, array('type' => 'SYNC', 'data' => $blob, 'license' => $helper->getLicenseKey(), 'entity' => $this->_getEntityType())));
         $helper->debug('Sending ' . count($data) . ' ' . $this->_getEntityType());
         //mark sent items
         if ($response->code == 'OK') {
             $this->markSentItems($data);
         }
         return true;
     } catch (Exception $e) {
         $helper->debug($e, Zend_Log::ERR);
         return false;
     }
 }
Example #12
0
        $pageheading = get_string('addinganewto', 'moodle', $heading);
    } else {
        $pageheading = get_string('addinganew', 'moodle', $fullmodulename);
    }
    $navbaraddition = $pageheading;
} else {
    if (!empty($update)) {
        $url->param('update', $update);
        $PAGE->set_url($url);
        // Select the "Edit settings" from navigation.
        navigation_node::override_active_url(new moodle_url('/course/modedit.php', array('update' => $update, 'return' => 1)));
        // Check the course module exists.
        $cm = get_coursemodule_from_id('', $update, 0, false, MUST_EXIST);
        // eClass Modification.
        if (extension_loaded('newrelic')) {
            newrelic_add_custom_parameter('courseid', $cm->course);
        }
        // Check the course exists.
        $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
        // require_login
        require_login($course, false, $cm);
        // needed to setup proper $COURSE
        list($cm, $context, $module, $data, $cw) = can_update_moduleinfo($cm);
        $data->coursemodule = $cm->id;
        $data->section = $cw->section;
        // The section number itself - relative!!! (section column in course_sections)
        $data->visible = $cm->visible;
        //??  $cw->visible ? $cm->visible : 0; // section hiding overrides
        $data->cmidnumber = $cm->idnumber;
        // The cm IDnumber
        $data->groupmode = groups_get_activity_groupmode($cm);
Example #13
0
/**
 * Registra parametro per la transazione su New Relic, se possibile
 * @param string    Nome del parametro
 * @param string    Valore del parametro
 * @return bool     Parametro registrato con successo?
 */
function registraParametroTransazione($nome, $valore)
{
    if (!function_exists('newrelic_add_custom_parameter')) {
        return false;
    }
    newrelic_add_custom_parameter($nome, $valore);
    return true;
}
Example #14
0
 * Authorized file system operations:
 *
 * The Update manager module included with Drupal provides a mechanism for
 * site administrators to securely install missing updates for the site
 * directly through the web user interface by providing either SSH or FTP
 * credentials. This allows the site to update the new files as the user who
 * owns all the Drupal files, instead of as the user the webserver is running
 * as. However, some sites might wish to disable this functionality, and only
 * update the code directly via SSH or FTP themselves. This setting completely
 * disables all functionality related to these authorized file operations.
 *
 * Remove the leading hash signs to disable.
 */
#$conf['allow_authorize_operations'] = FALSE;
$conf['blazedev'] = 0;
#$conf = array('blazedev' => '1');
#variable_set(blazedev, 1);
/**  Added for Memcached configuration */
$conf['cache_backends'][] = './sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
if (function_exists('newrelic_add_custom_parameter')) {
    if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
        newrelic_add_custom_parameter('remoteFwdIp', $_SERVER["HTTP_X_FORWARDED_FOR"]);
        newrelic_add_custom_parameter('customerIp', $_SERVER["HTTP_X_FORWARDED_FOR"]);
    } else {
        newrelic_add_custom_parameter('customerIp', $_SERVER["REMOTE_ADDR"]);
    }
    newrelic_add_custom_parameter('remoteIp', $_SERVER["REMOTE_ADDR"]);
    newrelic_add_custom_parameter('requestUri', $_SERVER["REQUEST_URI"]);
}
/**
 * Add the exact URI to NewRelic tracking but only if we're not in the admin
 */
function wpcom_vip_add_URI_to_newrelic()
{
    if (!is_admin() && function_exists('newrelic_add_custom_parameter')) {
        newrelic_add_custom_parameter('REQUEST_URI', $_SERVER['REQUEST_URI']);
        newrelic_add_custom_parameter('HTTP_REFERER', $_SERVER['HTTP_REFERER']);
        newrelic_add_custom_parameter('HTTP_USER_AGENT', $_SERVER['HTTP_USER_AGENT']);
    }
}
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function addCustomParameter($key, $value)
 {
     if (!$this->extensionLoaded()) {
         return $this;
     }
     newrelic_add_custom_parameter($key, $value);
     return $this;
 }
Example #17
0
 /**
  * Adds a custom parameter to current web transaction, e.g. customer's full
  * name.
  *
  * @param string $key Name of custom parameter
  * @param string $value Value of custom parameter
  */
 public function addCustomParameter($key, $value)
 {
     if ($this->skip()) {
         return;
     }
     newrelic_add_custom_parameter($key, $value);
 }
Example #18
0
 */
require_once '../config.php';
require_once 'lib.php';
require_once 'edit_form.php';
$id = optional_param('id', 0, PARAM_INT);
// Course id.
$categoryid = optional_param('category', 0, PARAM_INT);
// Course category - can be changed in edit form.
$returnto = optional_param('returnto', 0, PARAM_ALPHANUM);
// Generic navigation return page switch.
$PAGE->set_pagelayout('admin');
if ($id) {
    $pageparams = array('id' => $id);
    // eClass Modification.
    if (extension_loaded('newrelic')) {
        newrelic_add_custom_parameter('courseid', $id);
    }
} else {
    $pageparams = array('category' => $categoryid);
}
$PAGE->set_url('/course/edit.php', $pageparams);
// Basic access control checks.
if ($id) {
    // Editing course.
    if ($id == SITEID) {
        // Don't allow editing of  'site course' using this from.
        print_error('cannoteditsiteform');
    }
    // Login to the course and retrieve also all fields defined by course format.
    $course = get_course($id);
    require_login($course);
Example #19
0
$from = $_GET["from"] ?: 'now';
$filter = $_GET["filter"];
$filterstr = $filter ? strtolower($filter) : null;
$onlyVideo = !empty($_REQUEST['video']);
$all = !empty($_REQUEST['all']);
$repeat = !empty($_REQUEST['repeat']);
$nolimit = !empty($_REQUEST['nolimit']);
$csv = !strcasecmp($_GET["f"], 'csv');
if (isset($filterstr) && $supportsGrep) {
    $filterstr = trim(escapeshellarg(str_replace(array('"', "'", '\\'), '', trim($filterstr))), "'\"");
}
if (extension_loaded('newrelic')) {
    newrelic_add_custom_parameter('filter', $filter);
    newrelic_add_custom_parameter('days', $days);
    newrelic_add_custom_parameter('all', $all);
    newrelic_add_custom_parameter('nolimit', $nolimit);
}
$includeip = false;
$includePrivate = false;
if ($admin) {
    $includeip = (int) $_GET["ip"] == 1;
    $includePrivate = (int) $_GET["private"] == 1;
}
function check_it($val)
{
    if ($val) {
        echo ' checked ';
    }
}
if ($csv) {
    header("Content-type: text/csv");
Example #20
0
 /**
  * Post dispatch observer for user tracking
  *
  * @access public
  * @param Varien_Event_Observer $observer
  * @return $this
  */
 public function controllerActionPostdispatch($observer)
 {
     if (!$this->_isEnabled()) {
         return $this;
     }
     // Set generic data
     newrelic_add_custom_parameter('magento_controller', Mage::getModel('core/url')->getRequest()->getControllerModule());
     newrelic_add_custom_parameter('magento_request', Mage::getModel('core/url')->getRequest()->getRequestUri());
     newrelic_add_custom_parameter('magento_store_id', Mage::app()->getStore()->getId());
     // Get customer-data
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     $customerName = trim($customer->getName());
     $customerEmail = trim($customer->getEmail());
     // Correct empty values
     if (empty($customerName)) {
         $customerName = 'guest';
     }
     if (empty($customerEmail)) {
         $customerEmail = 'guest';
     }
     // Set customer-data
     newrelic_add_custom_parameter('magento_customer_email', $customerEmail);
     newrelic_add_custom_parameter('magento_customer_name', $customerName);
     // Get and set product-data
     $product = Mage::registry('current_product');
     if (!empty($product)) {
         $productSku = $product->getSku();
         newrelic_add_custom_parameter('magento_product_name', $product->getName());
         newrelic_add_custom_parameter('magento_product_sku', $product->getSku());
         newrelic_add_custom_parameter('magento_product_id', $product->getId());
     } else {
         $productSku = null;
     }
     $category = Mage::registry('current_category');
     if ($category) {
         newrelic_add_custom_parameter('magento_category_name', $category->getName());
         newrelic_add_custom_parameter('magento_category_id', $category->getId());
     }
     // Set user attributes
     if ($this->_getHelper()->isUseRUM()) {
         newrelic_set_user_attributes($customerEmail, $customerName, $productSku);
     }
     return $this;
 }
Example #21
0
 /**
  * {@inheritdoc}
  */
 public function addCustomParameter($key, $value)
 {
     if ($this->extensionLoaded()) {
         newrelic_add_custom_parameter($key, $value);
     }
 }
Example #22
0
require_once 'devtools.inc.php';
require_once './video/visualProgress.inc.php';
require_once './video/avi2frames.inc.php';
if (!isset($included)) {
    error_reporting(E_ERROR | E_PARSE);
    header('Content-type: text/plain');
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
}
set_time_limit(3600);
ignore_user_abort(true);
$key = $_REQUEST['key'];
$id = $_REQUEST['id'];
if (extension_loaded('newrelic')) {
    newrelic_add_custom_parameter('test', $id);
    newrelic_add_custom_parameter('location', $location);
}
$workdone_start = microtime(true);
//logmsg(json_encode($_REQUEST), './work/workdone.log', true);
// The following params have a default value:
$done = arrayLookupWithDefault('done', $_REQUEST, false);
$har = arrayLookupWithDefault('har', $_REQUEST, false);
$cpu = arrayLookupWithDefault('cpu', $_REQUEST, 0);
$pc = array_key_exists('pc', $_REQUEST) ? $_REQUEST['pc'] : '';
$ec2 = array_key_exists('ec2', $_REQUEST) ? $_REQUEST['ec2'] : '';
$tester = null;
if (strlen($ec2)) {
    $tester = $ec2;
} elseif (strlen($pc)) {
    $tester = $pc . '-' . trim($_SERVER['REMOTE_ADDR']);
} else {
 /**
  * Fetch locally stored file.
  *
  * @param int $contextid context ID
  * @param string $component component
  * @param string $filearea file area
  * @param int $itemid item ID
  * @param string $filepath file path
  * @param string $filename file name
  * @return stored_file|bool stored_file instance if exists, false if not
  */
 public function get_file($contextid, $component, $filearea, $itemid, $filepath, $filename)
 {
     $filepath = clean_param($filepath, PARAM_PATH);
     $filename = clean_param($filename, PARAM_FILE);
     if ($filename === '') {
         $filename = '.';
     }
     $pathnamehash = $this->get_pathname_hash($contextid, $component, $filearea, $itemid, $filepath, $filename);
     // eClass Modification
     if (extension_loaded('newrelic')) {
         newrelic_add_custom_parameter('pathnamehash', $pathnamehash);
     }
     return $this->get_file_by_hash($pathnamehash);
 }
Example #24
0
 public function setParameter($key, $value)
 {
     if (extension_loaded('newrelic')) {
         newrelic_add_custom_parameter($key, $value);
     }
 }
Example #25
0
 /**
  * @param $key
  * @param $value
  */
 public function setCustomParameter($key, $value)
 {
     if (!extension_loaded('newrelic')) {
         return;
     }
     newrelic_add_custom_parameter($key, $value);
 }
Example #26
0
 /**
  * Add a custom parameter to the current web transaction with the specified value. For example, you can add a
  * customer's full name from your customer database.
  *
  * @param string $key
  * @param mixed $value
  *
  * @return $this
  */
 public function addCustomParameter($key, $value)
 {
     if ($this->active) {
         newrelic_add_custom_parameter($key, $value);
     }
     return $this;
 }
 /**
  * track the template we're using
  */
 public function template_include($template)
 {
     newrelic_add_custom_parameter('template', $template);
     return $template;
 }
Example #28
0
 /**
  * Add custom params to newrelic
  * @param $key
  * @param $value
  * @return boolean true on success
  */
 public function addParam($key, $value)
 {
     return newrelic_add_custom_parameter($key, $value);
 }
Example #29
0
	if ( function_exists( 'newrelic_disable_autorum') ) {
		newrelic_disable_autorum();
	}
	if (is_object($wgRequest)) {
		$sharedWiki = (preg_match("/^slot[0-9]\$/",$wgDBname) || $wgDBname == 'devbox') ? "shared" : "local";
		$only = $wgRequest->getVal( 'only', 'full' );
		$modules = ResourceLoaderContext::expandModuleNames( $wgRequest->getVal( 'modules' ) );
		if ( count( $modules ) > 2 ) {
			$modules = count($modules) . '/' . $modules[0];
		} else {
			$modules = count($modules) . '/' . implode( ',', $modules );
		}
		newrelic_name_transaction( "/load/$sharedWiki/$only/$modules" );
		if ( function_exists( 'newrelic_add_custom_parameter' ) ) {
			newrelic_add_custom_parameter( 'skin', $wgRequest->getVal( 'skin' ) );
			newrelic_add_custom_parameter( 'lang', $wgRequest->getVal( 'lang' ) );
		}
        }
}


wfProfileIn( 'load.php' );

// URL safety checks
if ( !$wgRequest->checkUrlExtension() ) {
	return;
}

// Respond to resource loading request
$resourceLoader = new ResourceLoader();
$resourceLoader->respond( new ResourceLoaderContext( $resourceLoader, $wgRequest ) );
Example #30
0
/**
 * Log a custom param
 *
 * @param mixed $name name of the custom param
 * @param mixed $value of the custom param
 */
function apm_log_custom_param($name, $value)
{
    if (extension_loaded('newrelic')) {
        // New Relic is installed on the server for monitoring.
        newrelic_add_custom_parameter($name, $value);
    }
}