public function testAddCustomParameter() { $key = 'foo'; $value = 'bar'; $result = true; $handler = $this->getHandlerSpy('newrelic_add_custom_parameter', array($key, $value), $result); $agent = new Newrelic(false, $handler); $this->assertSame($result, $agent->addCustomParameter($key, $value)); }
/** * @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; }
/** * 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. This parameter is shown in any transaction trace that results * from this transaction. * * @param string $key * @param mixed $value * @return mixed * @static */ public static function addCustomParameter($key, $value) { return \Intouch\Newrelic\Newrelic::addCustomParameter($key, $value); }