Ejemplo n.º 1
0
 /**
  * @param string $name
  */
 public function startTransaction($name)
 {
     if ($this->getEnabled()) {
         $this->endTransaction();
         newrelic_start_transaction($this->_appName);
         $this->setNameTransaction($name);
     }
 }
Ejemplo n.º 2
0
 public static function start($name = null)
 {
     if (extension_loaded('newrelic')) {
         if (is_null($name)) {
             $name = ini_get("newrelic.appname");
         }
         newrelic_start_transaction($name);
     }
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 public function startTransaction()
 {
     if ($this->started) {
         $this->endTransaction();
     }
     if (extension_loaded('newrelic')) {
         newrelic_start_transaction($this->appname);
         newrelic_background_job($this->background);
         if ($this->output) {
             echo "\nStarting transaction " . $this->appname . ' ' . ($this->background ? '(background)' : '(frontground)') . "\n";
         }
     }
     $this->started = true;
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
 /**
  * Added in v. 3.0 of the New Relic Agent.
  *
  * @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-start-txn
  * @see endTransaction
  *
  * @param string $appname
  * @param string $license
  *
  * @return bool
  */
 public function startTransaction($appname, $license = null)
 {
     if (!$this->isLoaded()) {
         return false;
     }
     return newrelic_start_transaction($appname, $license ?: ini_get('newrelic.license'));
 }
Ejemplo n.º 7
0
function bapi_create_site()
{
    if (!preg_match('/bapi-signup\\.php$/', $_SERVER['REQUEST_URI'])) {
        return;
    }
    if (extension_loaded('newrelic')) {
        newrelic_start_transaction('WP InstaSites');
        newrelic_name_transaction('create-instasite');
    }
    if (isset($_POST['blogid']) && $_POST['blogid'] != 0) {
        header('Content-Type: application/javascript');
        $d = get_blog_details($_POST['blogid']);
        if ($d === false) {
            $new_site = array("status" => "error", "data" => array("errors" => array("blogid_invalid" => "Unable to locate blog with ID: " . $_POST['blogid']), "error_data" => ""));
            echo json_encode($new_site);
            if (extension_loaded('newrelic')) {
                newrelic_end_transaction();
            }
            exit;
        }
        switch_to_blog($_POST['blogid']);
        $blogid = get_current_blog_id();
        if ($blogid != $_POST['blogid']) {
            $new_site = array("status" => "error", "data" => array("errors" => array("blogid_switch_fail" => "Unable to switch to BlogID: " . $_POST['blogid']), "error_data" => ""));
            echo json_encode($new_site);
            if (extension_loaded('newrelic')) {
                newrelic_end_transaction();
            }
            exit;
        }
        //Do Update Stuff Here
        $prefix = $_POST['siteprefix'];
        $sname = $_POST['sitename'];
        $tagline = '';
        if (isset($_POST['tagline']) && !empty($_POST['tagline'])) {
            $tagline = $_POST['tagline'];
        }
        $apikey = "";
        if (isset($_POST['apikey']) && !empty($_POST['apikey'])) {
            $apikey = $_POST['apikey'];
        }
        $username = $_POST['username'];
        $password = $_POST['password'];
        $domain = $_SERVER['SERVER_NAME'];
        $siteurl = $prefix . '.' . $domain;
        //How to check which domain is used for current service
        $liveurl = 'http://' . $siteurl;
        if (isset($_POST['domain']) && !empty($_POST['domain'])) {
            $liveurl = $_POST['domain'];
            //bapi_site_cdn_domain
        }
        $cf_url = str_replace('http://', '', $liveurl);
        $cf_origin = str_replace('http://', '', $siteurl);
        $cf = modify_cf_distro($cf_origin, $cf_url);
        if ($cf['CreatingDistrib'] === false) {
            header('Content-Type: application/javascript');
            $new_site = array("status" => "error", "data" => array("errors" => array("cloudfront_distrib" => 'Error Creating CloudFront Distribution'), "message" => $cf['Message'], "error_data" => ""));
            echo json_encode($new_site);
            if (extension_loaded('newrelic')) {
                newrelic_end_transaction();
            }
            exit;
        }
        $liveurl = get_site_url();
        if (isset($_POST['domain']) && !empty($_POST['domain'])) {
            $liveurl = $_POST['domain'];
            //bapi_site_cdn_domain
        }
        update_option('bapi_site_cdn_domain', $liveurl);
        update_option('bapi_cloudfrontid', $cf['Id']);
        $new_site = array("status" => "success", "data" => array("blog_id" => $_POST['blogid'], "blog_url" => get_site_url()));
        echo json_encode($new_site);
        if (extension_loaded('newrelic')) {
            newrelic_end_transaction();
        }
        exit;
    }
    $prefix = $_POST['siteprefix'];
    $sname = $_POST['sitename'];
    $tagline = '';
    if (isset($_POST['tagline']) && !empty($_POST['tagline'])) {
        $tagline = $_POST['tagline'];
    }
    $apikey = "";
    if (isset($_POST['apikey']) && !empty($_POST['apikey'])) {
        $apikey = $_POST['apikey'];
    }
    $username = $_POST['username'];
    $password = $_POST['password'];
    $domain = $_SERVER['SERVER_NAME'];
    $siteurl = $prefix . '.' . $domain;
    //How to check which domain is used for current service
    $liveurl = 'http://' . $siteurl;
    if (isset($_POST['domain']) && !empty($_POST['domain'])) {
        $liveurl = $_POST['domain'];
        //bapi_site_cdn_domain
    }
    $cf_url = str_replace('http://', '', $liveurl);
    $cf_origin = str_replace('http://', '', $siteurl);
    if ($apikey == "") {
        header('Content-Type: application/javascript');
        $new_site = array("status" => "error", "data" => array("errors" => array("apikey_not_set" => "A valid API key is required."), "error_data" => ""));
        echo json_encode($new_site);
        if (extension_loaded('newrelic')) {
            newrelic_end_transaction();
        }
        exit;
    }
    $cf = create_cf_distro($cf_origin, $cf_url);
    if ($cf['CreatingDistrib'] === false) {
        header('Content-Type: application/javascript');
        $new_site = array("status" => "error", "data" => array("errors" => array("cloudfront_distrib" => 'Error Creating CloudFront Distribution'), "message" => $cf['Message'], "error_data" => ""));
        echo json_encode($new_site);
        if (extension_loaded('newrelic')) {
            newrelic_end_transaction();
        }
        exit;
    }
    $meta = array('api_key' => $apikey, 'bapi_secureurl' => '', 'bapi_site_cdn_domain' => $liveurl, 'bapi_cloudfronturl' => $cf['DomainName'], 'bapi_cloudfrontid' => $cf['Id'], 'blogdescription' => $tagline, 'bapi_first_look' => 1, 'blog_public' => 1);
    //http://codex.wordpress.org/Option_Reference#Privacy
    if (defined('BAPI_BASEURL') && BAPI_BASEURL == 'connect.bookt.biz') {
        $meta['bapi_secureurl'] = $prefix . '.lodgingcloud.com';
        $meta['bapi_baseurl'] = BAPI_BASEURL;
    }
    //$siteurl = $prefix.'.imbookingsecure.com';
    $u = username_exists($username);
    if (empty($u)) {
        $u = wpmu_create_user($username, $password, $username);
    }
    //$u = wpmu_create_user($username,$password,$username);
    if (is_numeric($u)) {
        $s = wpmu_create_blog($siteurl, '/', $sname, $u, $meta);
        //$t = wpmu_create_blog('wpmutest.localhost','/','Test1',1);  //use this one to force a 'blog_taken' failure.
        if (is_numeric($s)) {
            //success
            switch_to_blog($s);
            //echo get_site_url();exit();
            if (defined('KIGO_SELF_HOSTED') && !KIGO_SELF_HOSTED) {
                switch_theme(WP_DEFAULT_THEME);
            } else {
                switch_theme('instatheme01');
            }
            bapi_wp_site_options();
            //Initialize menu and pages
            //$path = '/bapi.init?p=1';
            //$url = get_site_url().$path;
            //$server_output = file_get_contents($url);
            //Provide response
            header('Content-Type: application/javascript');
            $new_site = array("status" => "success", "data" => array("blog_id" => $s, "blog_url" => get_site_url()));
            echo json_encode($new_site);
            if (extension_loaded('newrelic')) {
                newrelic_end_transaction();
            }
        } else {
            //fail
            //print_r($s->errors['blog_taken'][0]); exit();  //Not sure if this is the only error returned.  Need a more generic message handler.
            header('Content-Type: application/javascript');
            $new_site = array("status" => "error", "data" => $s);
            echo json_encode($new_site);
            if (extension_loaded('newrelic')) {
                newrelic_end_transaction();
            }
            exit;
        }
    } else {
        header('Content-Type: application/javascript');
        $new_site = array("status" => "error", "data" => array("errors" => array("user_unknown" => "Sorry, the username specified is invalid."), "error_data" => ""));
        echo json_encode($new_site);
        if (extension_loaded('newrelic')) {
            newrelic_end_transaction();
        }
        exit;
    }
    exit;
}
Ejemplo n.º 8
0
 public function setName($name)
 {
     return newrelic_start_transaction($name, $this->licenseKey);
 }
Ejemplo n.º 9
0
<?php

$loaded = extension_loaded("newrelic");
print "newrelic loaded: " . $loaded . "\n";
print "newrelic_start_transaction exists: " . function_exists("newrelic_start_transaction") . "\n";
print "newrelic_name_transaction exists: " . function_exists("newrelic_name_transaction") . "\n";
print "newrelic_transaction_set_request_url exists: " . function_exists("newrelic_transaction_set_request_url") . "\n";
print "newrelic_transaction_set_threshold exists: " . function_exists("newrelic_transaction_set_threshold") . "\n";
print "newrelic_end_transaction exists: " . function_exists("newrelic_end_transaction") . "\n";
print "newrelic_segment_generic_begin exists: " . function_exists("newrelic_segment_generic_begin") . "\n";
print "newrelic_segment_datastore_begin exists: " . function_exists("newrelic_segment_datastore_begin") . "\n";
print "newrelic_segment_end exists: " . function_exists("newrelic_segment_end") . "\n";
$transaction_id = newrelic_start_transaction();
print "transaction_id: " . $transaction_id . "\n";
$name_error_code = newrelic_name_transaction("my_transaction");
print "name_error_code: " . $name_error_code . "\n";
$request_url_error_code = newrelic_transaction_set_request_url("my/path");
print "request_url_error_code: " . $name_error_code . "\n";
$generic_segment_id = newrelic_segment_generic_begin("my_segment");
print "generic_segment_id: " . $generic_segment_id . "\n";
sleep(2);
$datastore_segment_id = newrelic_segment_datastore_begin("my_table", "select");
print "datastore_segment_id: " . $datastore_segment_id . "\n";
sleep(1);
$datastore_end_error_code = newrelic_segment_end($datastore_segment_id);
print "datastore_end_error_code: " . $datastore_end_error_code . "\n";
$generic_end_error_code = newrelic_segment_end($generic_segment_id);
print "generic_end_error_code: " . $generic_end_error_code . "\n";
$end_error_code = newrelic_end_transaction();
print "end_error_code: " . $end_error_code . "\n";
Ejemplo n.º 10
0
 /**
  * If you have ended a transaction before your script terminates (perhaps
  * due to it just having finished a task in a job queue manager) and you
  * want to start a new transaction, use this call. This will perform the
  * same operations that occur when the script was first started. Of the
  * two arguments, only the application name is mandatory. However, if you
  * are processing tasks for multiple accounts, you may also provide a
  * license for the associated account. The license set for this API call
  * will supersede all per-directory and global default licenses configured
  * in INI files
  * 
  * @param string $appName The application name
  * @param string $license The application license, optional
  * @since 3.0
  */
 public function startTransaction($appName, $license = null)
 {
     if ($this->skip()) {
         return;
     }
     newrelic_start_transaction($appName, $license);
 }
 /**
  * {@inheritdoc}
  */
 public function startTransaction($name)
 {
     newrelic_start_transaction($name);
 }