public static function trackTransaction()
 {
     eZExecution::addCleanupHandler(function () {
         $newrelic = new Newrelic(true);
         $newrelic->nameTransaction(self::buildCurrentTransactionName());
     });
 }
Beispiel #2
0
 /**
  * @param Request $request
  * @param int     $type
  * @param bool    $catch
  *
  * @return Response|void
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     if ($type === HttpKernelInterface::SUB_REQUEST) {
         if ($request->attributes->get('exception') instanceof \Exception) {
             $e = $request->attributes->get('exception');
             $this->newRelic->noticeError($e->getMessage(), $e);
         }
         return $this->app->handle($request, $type, $catch);
     }
     foreach ($this->loggerFactory->getTags() as $name => $value) {
         $this->newRelic->addCustomParameter($name, $value);
     }
     $this->newRelic->addCustomParameter('url', $request->getPathInfo());
     $this->newRelic->addCustomParameter('content_type', $request->getContentType());
     $routeName = $request->attributes->get('_route');
     if (null !== $routeName) {
         $routeName = explode('.', $routeName);
         $this->newRelic->nameTransaction($routeName[0]);
     }
     $response = $this->app->handle($request, $type, $catch);
     $this->newRelic->addCustomParameter('result_code', $response->getStatusCode());
     return $response;
 }
 public function testNameTransaction()
 {
     $name = 'foo';
     $result = true;
     $handler = $this->getHandlerSpy('newrelic_name_transaction', array($name), $result);
     $agent = new Newrelic(false, $handler);
     $this->assertSame($result, $agent->nameTransaction($name));
 }
Beispiel #4
0
 /**
  * Sets the name of the transaction to the specified string. This can be useful if you have implemented your own
  * dispatching scheme and wish to name transactions according to their purpose rather than their URL.
  * 
  * Avoid creating too many unique transaction names. For example, if you have /product/123 and /product/234, if you
  * generate a separate transaction name for each, then New Relic will store separate information for these two
  * transaction names. This will make your graphs less useful, and may run into limits we set on the number of unique
  * transaction names per account. It also can slow down the performance of your application. Instead, store the
  * transaction as /product/*, or use something significant about the code itself to name the transaction, such as
  * /Product/view. The limit for the total number of transactions should be less than 1000 unique transaction
  * names -- exceeding that is not recommended.
  *
  * @param string $name
  * @return mixed 
  * @static 
  */
 public static function nameTransaction($name)
 {
     return \Intouch\Newrelic\Newrelic::nameTransaction($name);
 }