/**
  * NewrelicMiddleware constructor.
  *
  * @param HttpKernelInterface $app
  * @param string                   $applicationName
  * @param LoggerFactory       $loggerFactory
  */
 public function __construct(HttpKernelInterface $app, $applicationName, LoggerFactory $loggerFactory)
 {
     $this->app = $app;
     $this->applicationName = $applicationName;
     $this->loggerFactory = $loggerFactory;
     $this->newRelic = new \Intouch\Newrelic\Newrelic(false);
     $this->newRelic->setAppName($applicationName);
 }
 public function testSetAppName()
 {
     $name = 'foo';
     $licence = 'bar9000';
     $xmit = false;
     $result = true;
     $handler = $this->getHandlerSpy('newrelic_set_appname', array($name, $licence, $xmit), $result);
     $agent = new Newrelic(false, $handler);
     $this->assertSame($result, $agent->setAppName($name, $licence, $xmit));
 }
Exemple #3
0
 /**
  * Sets the name of the application to name. The string uses the same format as newrelic.appname and can set
  * multiple application names by separating each with a semi-colon. However please be aware of the restriction on
  * the application name ordering as described for that setting.
  * 
  * The first application name is the primary name, and up to two extra application names can be specified (however
  * the same application name can only ever be used once as a primary name). This function should be called as early
  * as possible, and will have no effect if called after the RUM footer has been sent. You may want to consider
  * setting the application name in a file loaded by PHP's auto_prepend_file INI setting. This function returns true
  * if it succeeded or false otherwise.
  * 
  * If you use multiple licenses you can also specify a license key along with the application name. An application
  * can appear in more than one account and the license key controls which account you are changing the name in.
  * If you do not wish to change the license and wish to use the third variant, simply set the license key to the
  * empty string ("").
  * 
  * The xmit flag is new in version 3.1 of the agent. Usually, when you change an application name, the agent simply
  * discards the current transaction and does not send any of the accumulated metrics to the daemon. However, if you
  * want to record the metric and transaction data up to the point at which you called this function, you can specify
  * a value of true for this argument to make the agent send the transaction to the daemon. This has a very slight
  * performance impact as it takes a few milliseconds for the agent to dump its data. By default this parameter is
  * false.
  *
  * @param string $name
  * @param string $license
  * @param bool $xmit
  * @return bool 
  * @static 
  */
 public static function setAppName($name, $license = '', $xmit = false)
 {
     return \Intouch\Newrelic\Newrelic::setAppName($name, $license, $xmit);
 }