/** * @param PostResponseEvent $event */ public function onKernelTerminate(PostResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if ($span = $this->spanStack->pop()) { $this->tracer->trace([$this->httpFoundationSpanFactory->fromOutgoingResponse($event->getResponse(), $span)]); } }
/** * {@inheritdoc} */ public function execute(AMQPMessage $msg) { $span = $this->amqpSpanFactory->fromReceivedMessage($msg); $this->tracer->trace([$span]); $this->spanStack->push($span); $result = $this->decoratedConsumer->execute($msg); $this->tracer->trace([$this->amqpSpanFactory->fromConsumedMessage($msg)]); $this->spanStack->pop(); return $result; }
function it_do_not_trace_if_no_request_in_stack(Tracer $tracer, SpanStack $spanStack, Span $span, PostResponseEvent $event) { $event->isMasterRequest()->willReturn(true); $spanStack->pop()->willReturn(null); $tracer->trace(Argument::any())->shouldNotBeCalled(); $this->onKernelTerminate($event); }
function it_adds_the_span_in_the_stack_during_the_execution(ConsumerInterface $decoratedConsumer, SpanStack $spanStack) { $message = new AMQPMessage(''); $spanStack->push(Argument::type(Span::class))->shouldBeCalled(); $decoratedConsumer->execute($message)->shouldBeCalled(); $spanStack->pop()->shouldBeCalled(); $this->execute($message); }