Beispiel #1
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 testNoticeErrorWithoutException()
 {
     $message = 'foo';
     $result = true;
     $handler = $this->getHandlerSpy('newrelic_notice_error', array($message), $result);
     $agent = new Newrelic(false, $handler);
     $this->assertSame($result, $agent->noticeError($message));
 }
Beispiel #3
0
 /**
  * Report an error at this line of code, with a complete stack trace. The third form of the call was added in agent
  * version 2.6 and should be used for reporting exceptions. Only the exception for the last call is retained during
  * the course of a transaction.
  * 
  * The exception parameter must be a valid PHP Exception class, and the stack frame recorded in that class will be
  * the one reported, rather than the stack at the time this function was called. When using this form, if the error
  * message is empty, a standard message in the same format as created by Exception::__toString() will be
  * automatically generated.
  * 
  * NOTE: You should always pass an exception here if possible.
  *
  * @param string $message
  * @param \Exception|null $exception
  * @return mixed 
  * @static 
  */
 public static function noticeError($message, $exception = null)
 {
     return \Intouch\Newrelic\Newrelic::noticeError($message, $exception);
 }