public function testInvoke() { $requestId = new RequestId(new Generator(), true); $processor = new Processor($requestId, true); $extra = $processor(array()); $this->assertEquals(array('extra' => array('request_id' => $requestId->getRequestId(), 'pid' => $requestId->getPid())), $extra); }
public function testOnRequestBeforeSend() { $requestId = new RequestId(new Generator(), true); $guzzzleAdapter = new Guzzle($requestId); $event = new Event(); $request = new Request('GET', 'test'); $event->offsetSet('request', $request); $guzzzleAdapter->onRequestBeforeSend($event); $this->assertEquals($requestId->getRequestId(), $event['request']->getHeader("X-RequestId")); }
/** * @param GetResponseEvent $event */ public function onCoreRequest(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { $request = $event->getRequest(); if ($request->headers->has("X-RequestId")) { $requestId = $request->headers->get("X-RequestId"); if ($this->logger) { $this->logger->info(sprintf("MonitoringBundle : using requestId %s", $requestId)); } $this->requestId->setRequestId($requestId); } } }
/** * @param RequestId $requestId */ public function __construct(RequestId $requestId) { $this->requestId = $requestId->getRequestId(); }