/**
  * Tests one message handle
  */
 public function testHandleOne()
 {
     $handler = new UdpHandler($this->testHost, $this->testPort, $this->testTimeout);
     $handler->setFactory($this->mockFactory);
     // Normal metric
     $metric1 = new CounterMetric('metric_name1', 10);
     $metric1->setSampleRate(0.5);
     $expectedMessage = self::$formatter->format($metric1);
     $this->mockSocket->shouldReceive('write')->withArgs([$expectedMessage])->once();
     $handler->handle($metric1);
 }
 /**
  * Tests sampling
  */
 public function testMetricSample()
 {
     $metric1 = new CounterMetric('metric_name1', 10);
     $metric1->setSampleRate(0.2);
     $expected1 = 'metric_name1 value=' . 10 * 0.2;
     $this->assertEquals($expected1, $this->formatter->format($metric1));
 }
Example #3
0
 /**
  * @iterations 1000
  */
 public function counterNameTagsAndSample()
 {
     $this->formatter->format($this->metricTagsSample);
 }