/**
  * @test
  */
 public function preConsume_with_postConsume_should_add_timing_entry()
 {
     $timing = 2342;
     $deliveryTag = 1;
     $consumerName = 'consumer';
     $eventName = $consumerName . '-' . $deliveryTag;
     $message = new AMQPMessage('body');
     $message->delivery_info['delivery_tag'] = $deliveryTag;
     $container = $this->prophesize(ConsumerContainer::class);
     $container->getConsumerName()->willReturn($consumerName);
     $args = new ConsumerEvent($message, $container->reveal());
     $event = $this->prophesize(StopwatchEvent::class);
     $event->getDuration()->willReturn($timing);
     $this->stopwatch->start($eventName)->shouldBeCalled();
     $this->stopwatch->stop($eventName)->willReturn($event->reveal());
     $this->subscriber->preConsume($args);
     $this->subscriber->postConsume($args);
     $this->statsdClient->timing($consumerName, $timing)->shouldHaveBeenCalled();
 }
 /**
  * @param ConsumerEvent $args
  */
 public function postConsume(ConsumerEvent $args)
 {
     $consumerName = $args->getConsumerContainer()->getConsumerName();
     $event = $this->stopwatch->stop($this->getEventName($args));
     $this->statsdClient->timing($consumerName, $event->getDuration());
 }
Exemplo n.º 3
0
 /**
  * Timing
  *
  * @param  string $metric Metric to track
  * @param  float $time Time in seconds
  * @return $this
  */
 public function timing($metric, $time)
 {
     // We convert time in seconds because this is what the client requires.
     $this->client->timing($metric, round(1000 * $time, 4));
     return $this;
 }